Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async update(entry: EditSettingDto): Promise {
if (entry.id) {
const result = await Db.Setting.findOneAndUpdate(
{ _id: entry.id },
{ $set: entry },
{ upsert: true, 'new': true }).exec();
return this.pure(result);
} else {
throw new Errors.BadRequestError('settings not found');
}
}
export function validator(req: Request): Request {
if (req.body.userId != undefined) {
throw new Errors.BadRequestError("userId not present");
} else {
return req
}
}
async update(
entry: EditMenuDto,
): Promise {
if (entry.id === entry.parent) {
throw new Errors.BadRequestError('can not be set parent by self.');
}
const doc: any = await Db.Menu.findOneAndUpdate(
{
_id: entry.id,
},
entry,
).exec();
return doc;
}
entry, { upsert: true, new: true },
).exec();
entry.profile = profile._id;
const account = await Db.Account.findOneAndUpdate(
{
_id: request.user.id,
},
entry, { new: true },
).populate('profile').exec();
if (profile) {
const instance = Repository.mergeProfile(account);
return instance;
} else {
throw new Errors.BadRequestError('user not found');
}
}
async update(
entry: EditGroupDto,
): Promise {
if (entry.id === entry.parent) {
throw new Errors.BadRequestError('can not be set parent by self.');
}
const doc: any = await Db.Group.findOneAndUpdate(
{
_id: entry.id,
},
entry,
).exec();
return doc;
}
async update(
entry: EditCategoryDto,
): Promise {
if (entry.id === entry.parent) {
throw new Errors.BadRequestError('can not be set parent by self.');
}
const doc: any = await Db.Category.findOneAndUpdate(
{
_id: entry.id,
},
entry,
).exec();
return doc;
}