async function updateOne(collectionname,json1,json2){ const client = new MongoClient(url, {useUnifiedTopology: true}); await client.connect(); const col = client.db("spider").collection(collectionname); const result = await col.updateOne(json1,{$set:json2}); client.close(); return result; }
updateSchedule(param,schedule,options){ try{ schedule = this.checkAtomacity(schedule); this.schedules.updateOne(param, schedule,options); }catch(err){ console.error(err); } }
async updateCasualties(param, cas, options){ try{ cas = Object.prototype.hasOwnProperty.call(cas,"$set") || Object.prototype.hasOwnProperty.call(cas,"$inc") ? cas : {$set: cas}; return this.casualties.updateOne(param, cas,options); }catch(err){ console.error(err); } }
updateSignup(param, signup, options){ if (!param.season){ param.season = "season 15"; } try{ signup = this.checkAtomacity(signup); this.signups.updateOne(param,signup,options); }catch(err){ console.error(err); } }
client.connect(err => { const collection = client.db("noahdb").collection("questions"); var myquery = { address: "Highway 39" }; var newvalues = { $set: {name: "Mickey", address: "Highway 39" } }; collection.updateOne(myquery, newvalues, function(err, res) { if (err) throw err; console.log("1 document updated"); }); client.close(); });
// Used to both create and update events. NOTE doUpsert=true is only used by demoData loading script createOrUpdateEvent(event, doUpsert) { if (event._id) { return this.db.collection(this.EVENT_COLLECTION).updateOne({_id: event._id, type: event.type}, {$set: event}, {upsert: doUpsert}); } else { // Create a random short-code style id for new events // IMPORTANT! // We have to create our own id as a string, because Azure Functions can't handle MongoDB self generated ids event._id = utils.makeId(5); return this.db.collection(this.EVENT_COLLECTION).insertOne(event); } }
updatePlayer(param,player,options){ try{ player = this.checkAtomacity(player); this.players.updateOne(param, player,options); }catch(err){ console.error(err); } }
updateDivision(param, division, options){ try{ division = this.checkAtomacity(division); this.divisions.updateOne(param,division,options); }catch(err){ console.error(err); } }
updateMatchDate(param,match,options){ try{ match = this.checkAtomacity(match); this.matchDates.updateOne(param,match,options); } catch(err){ console.error(err); } }
updateUnplayedGame(param, game, options){ try{ game = this.checkAtomacity(game); this.unplayedGames.updateOne(param, game,options); }catch(err){ console.error(err); } }
updateTrophy(param, trophy, options){ try{ trophy =this.checkAtomacity(trophy); this.trophies.updateOne(param, trophy,options); }catch(err){ console.error(err); } }
updateStanding(param,standing,options){ try{ standing = this.checkAtomacity(standing); this.standings.updateOne(param, standing,options); }catch(err){ console.error(err); } }
updateAccount(param,account,options){ try{ account = this.checkAtomacity(account); this.accounts.updateOne(param, account,options); }catch(err){ console.error(err); } }
updateDraft(param, draft, options){ try{ draft = this.checkAtomacity(draft); this.drafts.updateOne(param,draft,options); }catch(err){ console.error(err); } }
async updateScheduleAsync (param,schedule,options){ try{ schedule = this.checkAtomacity(schedule); await this.schedules.updateOne(param, schedule,options); }catch(err){ console.error(err); } }