File tree Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Expand file tree Collapse file tree 3 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ export default class MongoCollection {
64
64
return this . _mongoCollection . update ( query , update , { upsert : true } ) ;
65
65
}
66
66
67
+ updateMany ( query , update ) {
68
+ return this . _mongoCollection . updateMany ( query , update ) ;
69
+ }
70
+
67
71
// Atomically find and delete an object based on query.
68
72
// The result is the promise with an object that was in the database before deleting.
69
73
// Postgres Note: Translates directly to `DELETE * FROM ... RETURNING *`, which will return data after delete is done.
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ DatabaseController.prototype.collection = function(className) {
35
35
throw new Parse . Error ( Parse . Error . INVALID_CLASS_NAME ,
36
36
'invalid className: ' + className ) ;
37
37
}
38
- return this . rawCollection ( className ) ;
38
+ return this . adapter . collection ( this . collectionPrefix + className ) ;
39
39
} ;
40
40
41
41
DatabaseController . prototype . adaptiveCollection = function ( className ) {
@@ -46,10 +46,6 @@ DatabaseController.prototype.collectionExists = function(className) {
46
46
return this . adapter . collectionExists ( this . collectionPrefix + className ) ;
47
47
} ;
48
48
49
- DatabaseController . prototype . rawCollection = function ( className ) {
50
- return this . adapter . collection ( this . collectionPrefix + className ) ;
51
- } ;
52
-
53
49
DatabaseController . prototype . dropCollection = function ( className ) {
54
50
return this . adapter . dropCollection ( this . collectionPrefix + className ) ;
55
51
} ;
Original file line number Diff line number Diff line change @@ -63,23 +63,19 @@ export class PushController extends AdaptableController {
63
63
let badgeUpdate = Promise . resolve ( ) ;
64
64
65
65
if ( body . badge ) {
66
- var op = { } ;
66
+ let op = { } ;
67
67
if ( body . badge == "Increment" ) {
68
- op = { ' $inc' : { ' badge' : 1 } }
68
+ op = { $inc : { badge : 1 } }
69
69
} else if ( Number ( body . badge ) ) {
70
- op = { ' $set' : { ' badge' : body . badge } }
70
+ op = { $set : { badge : body . badge } }
71
71
} else {
72
72
throw "Invalid value for badge, expected number or 'Increment'" ;
73
73
}
74
74
let updateWhere = deepcopy ( where ) ;
75
+ updateWhere . deviceType = 'ios' ; // Only on iOS!
75
76
76
- // Only on iOS!
77
- updateWhere . deviceType = 'ios' ;
78
-
79
- // TODO: @nlutsenko replace with better thing
80
- badgeUpdate = config . database . rawCollection ( "_Installation" ) . then ( ( coll ) => {
81
- return coll . update ( updateWhere , op , { multi : true } ) ;
82
- } ) ;
77
+ badgeUpdate = config . database . adaptiveCollection ( "_Installation" )
78
+ . then ( coll => coll . updateMany ( updateWhere , op ) ) ;
83
79
}
84
80
85
81
return badgeUpdate . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments