Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id": "5aa9535c6c4f437de713452a",
- ...
- "ht_score": "[0-1]",
- "ft_score": "[1-3]",
- "et_score": null,
- "penalty_local": null,
- "penalty_visitor": null,
- "comp_name": "UEFA Champions League",
- "predictions": [
- {
- "name": "Ilker Baltaci",
- "userid": "*******",
- "userFbid": "*****",
- "local_team_score": "3",
- "away_team_score": "1",
- "status": "FT"
- },
- {
- "name": "M. Mustermann",
- "userid": "*******",
- "userFbid": "*****",
- "status": "FT"
- }
- ],
- "match_id": "2324756"
- }
- var bulk = db.collection('bets').initializeUnorderedBulkOp();
- return new Promise(function (resolve, reject) {
- try {
- predictions.forEach(function (currentPrediction) {
- //Find one and update
- let match = games[currentPrediction.match_id];
- const query = {'_id': new ObjectID(currentPrediction._id)};
- bulk.find(query).update(
- {
- $set: {
- status: match.status,
- timer: match.timer,
- localteam_score: match.localteam_score,
- visitorteam_score: match.visitorteam_score,
- ht_score: match.ht_score,
- ft_score: match.ft_score,
- et_score: match.et_score,
- penalty_local: match.penalty_local,
- penalty_visitor: match.penalty_visitor,
- "predictions.$[].status" : "FT"
- }
- },{ multi: true });
- })
- bulk.execute(function (err) {
- resolve(predictions)
- });
- }
- catch
- (e) {
- reject(e);
- }
- }
Add Comment
Please, Sign In to add comment