Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
findOneAndUpdate(className, schema, query, update, upsert = false) : Promise {
update = this.transformDateObject(update);
schema = Transform.convertParseSchemaToMongoSchema(schema);
update = Transform.transformUpdate(className, update, schema);
update = this.transformDateObject(update);
query = this.transformDateObject(query);
query = Transform.transformWhere(className, query, schema);
query = this.transformDateObject(query);
return this._adaptiveCollection(className).ensureUniqueness(update['$set'])
.then(count => {
if (count === 0) {
return this._adaptiveCollection(className).updateOne(query, update, upsert);
} else {
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
}
})
.then(result => Transform.transformToParseObject(className, result.value, schema))
.catch(
error => { throw error }
updateObjectsByQuery(className, schema, query, update) : Promise {
update = this.transformDateObject(update);
schema = Transform.convertParseSchemaToMongoSchema(schema);
update = Transform.transformUpdate(className, update, schema);
update = this.transformDateObject(update);
query = this.transformDateObject(query);
query = Transform.transformWhere(className, query, schema);
query = this.transformDateObject(query);
return this._adaptiveCollection(className).ensureUniqueness(update['$set'])
.then(count => {
if (count === 0) {
return this._adaptiveCollection(className).updateMany(query, update);
} else {
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'A duplicate value for a field with unique values was provided');
}
})
.catch(
error => { throw error }
);