649 var sortOption = row.sortFindings.find(
650 e => e.category === (finding.category || 'No Category'),
651 );
652 if ((sortOption && sortOption.sortAuto) || !sortOption) 653 // if sort is set to automatic or undefined then we sort (default sort will be applied to undefined sortOption)
654 return Audit.updateSortFindings(isAdmin, auditId, userId, null);
655 // if manual sorting then we do not sort
549// Update audit general information
550AuditSchema.statics.updateGeneral = (isAdmin, auditId, userId, update) => {
551 return new Promise(async (resolve, reject) => {
552 if (update.company && update.company.name) { 553 var Company = mongoose.model('Company');
554 try {
555 update.company = await Company.create({ name: update.company.name });
173 }}
174 placeholder={t('search')}
175 type="text"
176 value={(filters && filters[column.accessor]) ?? ''}177 />
178 ) : null}
179 </div>
58 client.cell = req.body.cell || null;
59 client.title = req.body.title || null;
60 var company = null;
61 if (req.body.company && req.body.company.name)62 company = req.body.company.name;
63
64 Client.update(req.params.id, client, company)
35 if (req.body.cell) client.cell = req.body.cell;
36 if (req.body.title) client.title = req.body.title;
37 var company = null;
38 if (req.body.company && req.body.company.name)39 company = req.body.company.name;
40
41 Client.create(client, company)
The optional chaining operator can be used to perform null checks before accessing a property, or calling a function.
Using &&
for this purpose is no longer required.
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user && user.name
}
someFunc && someFunc()
// ^~~~ not necessary
maybeArray && maybeArray[index]
// ^~~~ not necessary
function getUsernameFromId(id: number): string | undefined {
const user = db.getUser(id)
return user?.name
}
someFunc?.()
maybeArray?.[index]