1145// Update audit parent
1146AuditSchema.statics.updateParent = (isAdmin, auditId, userId, parentId) => {
1147 return new Promise(async (resolve, reject) => {
1148 var query = Audit.findByIdAndUpdate(auditId, { parentId: parentId });1149 if (!isAdmin) query.or([{ creator: userId }, { collaborators: userId }]);
1150 query
1151 .exec()
989 sortAuto: true,
990 }; // set a default sort option
991
992 return { category: key, findings: value, sortOption: sortOption }; 993 })
994 .value();
995
234
235 var auditType = {
236 name: 'Web',
237 templates: templates,238 };
239 var response = await request(app)
240 .post('/api/data/audit-types')
214
215 var auditType = {
216 name: 'Web',
217 templates: templates,218 };
219 var response = await request(app)
220 .post('/api/data/audit-types')
192
193 var auditType = {
194 name: 'Wifi',
195 templates: templates,196 stage: 'itdoesnotexist',
197 };
198
ECMAScript 6 provides a concise form for defining object literal methods and properties. This syntax can make defining complex object literals much cleaner.
Here are a few common examples using the ES5 syntax:
const x = 1, y = 2, z = 3;
// properties
const foo = {
x: x,
y: y,
z: z,
};
// methods
const foo = {
a: function() {},
b: function() {}
};
The ES6 equivalent syntax is::
// properties
const foo = {x, y, z};
// methods
const bar = {
a() { return 1 },
b() { return 2 }
};
NOTE: The shorthand properties are equivalent to function expressions.
Meaning that they do not bind their own this
inside their bodies.
It is still possible to access properties from the object inside a shorthand member function:
const object = {
x: 1,
getX() {
return this.x // valid
}
}
const foo = {
bar: function () { return 1 }
};
const foo = {
bar() { return 1 }
}