Every line of 'mongoose updateone' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
128 updateOne(query, update) { 129 return this._mongoCollection.updateOne(query, update); 130 }
18 update (query, data) { 19 return this.table.updateOne(query, { 20 $set: data 21 }); 22 }
94 findOneAndUpdate(collection, query, values, options) { 95 var that = this; 96 query = castQueryIds(query); 97 if (!options) { 98 options = {}; 99 } 100 101 // Always return the updated object 102 options.returnOriginal = false; 103 104 return new Promise(function(resolve, reject) { 105 var db = that._mongo.collection(collection); 106 107 var update = values; 108 if (options.upsert) { 109 update = { $setOnInsert: update }; 110 } else { 111 update = { $set: update }; 112 } 113 114 db.findOneAndUpdate(query, update, options, function(error, result) { 115 if (error) return reject(error); 116 resolve(result.value); 117 }); 118 }); 119 }
89 updateOne(criteria: Object, updateDocument: Object, callback?: ResultCallback): void { 90 91 var query = this._createQuery(QueryKind.UpdateOne); 92 query.criteria = criteria; 93 query.updateDocument = updateDocument; 94 query.handleCallback(callback); 95 }
102 updateOne(query, update) { 103 return this.constructor._getCollection(this.collection) 104 .then(function(db) { 105 return new Promise((resolve, reject) => { 106 db.update(query, update, { multi: false }, function (err, numAffected) { 107 if(err) { 108 reject(err); 109 } 110 else { 111 resolve(numAffected); 112 } 113 }); 114 }); 115 }); 116 }
30 async update( 31 entry: IdentifyEntry, 32 fields: string[] = this.defaultQueryFields 33 ): Promise { 34 const instance = await this.model 35 .findOneAndUpdate( 36 { _id: entry.id }, 37 { $set: entry }, 38 { upsert: true, fields: this.getFields(fields), new: true } 39 ) 40 .exec(); 41 return instance; 42 }
103 function update ( data, callback ){ 104 105 callback = callback || function(){}; 106 107 player.findOneAndUpdate({'info.id': data.info.id}, data, function (error, foundPlayer) { 108 109 if (error){ 110 console.log(error); 111 } 112 113 return callback( foundPlayer ); 114 115 //console.log(foundPlayer); 116 }); 117 }
104 async updateOne(filter, document, opts) { 105 const result = await this.collection.updateOne(filter, document, opts); 106 return result; 107 }
25 async findOneAndUpdate(id, data) { 26 const query = {_id: ObjectId(id)}; 27 const modifier = {$set: data}; 28 const options = {returnOriginal: false}; 29 const operation = await this.db 30 .collection(this.name) 31 .findOneAndUpdate(query, modifier, options); 32 33 if (!operation.value) { 34 throw new Error('Db findOneAndUpdate error'); 35 } 36 return operation.value; 37 }
349 updateMany(query: ObjectLiteral, update: ObjectLiteral, options?: { upsert?: boolean, w?: any, wtimeout?: number, j?: boolean }): Promise { 350 return this.manager.updateMany(this.metadata.tableName, query, update, options); 351 }