Skip to content

Commit f2ead46

Browse files
committed
Remove .rawCollection method from DatabaseController.
1 parent 7909f0e commit f2ead46

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/Adapters/Storage/Mongo/MongoCollection.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ export default class MongoCollection {
6464
return this._mongoCollection.update(query, update, { upsert: true });
6565
}
6666

67+
updateMany(query, update) {
68+
return this._mongoCollection.updateMany(query, update);
69+
}
70+
6771
// Atomically find and delete an object based on query.
6872
// The result is the promise with an object that was in the database before deleting.
6973
// Postgres Note: Translates directly to `DELETE * FROM ... RETURNING *`, which will return data after delete is done.

src/Controllers/DatabaseController.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ DatabaseController.prototype.collection = function(className) {
3535
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,
3636
'invalid className: ' + className);
3737
}
38-
return this.rawCollection(className);
38+
return this.adapter.collection(this.collectionPrefix + className);
3939
};
4040

4141
DatabaseController.prototype.adaptiveCollection = function(className) {
@@ -46,10 +46,6 @@ DatabaseController.prototype.collectionExists = function(className) {
4646
return this.adapter.collectionExists(this.collectionPrefix + className);
4747
};
4848

49-
DatabaseController.prototype.rawCollection = function(className) {
50-
return this.adapter.collection(this.collectionPrefix + className);
51-
};
52-
5349
DatabaseController.prototype.dropCollection = function(className) {
5450
return this.adapter.dropCollection(this.collectionPrefix + className);
5551
};

src/Controllers/PushController.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,19 @@ export class PushController extends AdaptableController {
6363
let badgeUpdate = Promise.resolve();
6464

6565
if (body.badge) {
66-
var op = {};
66+
let op = {};
6767
if (body.badge == "Increment") {
68-
op = {'$inc': {'badge': 1}}
68+
op = { $inc: { badge: 1 } }
6969
} else if (Number(body.badge)) {
70-
op = {'$set': {'badge': body.badge } }
70+
op = { $set: { badge: body.badge } }
7171
} else {
7272
throw "Invalid value for badge, expected number or 'Increment'";
7373
}
7474
let updateWhere = deepcopy(where);
75+
updateWhere.deviceType = 'ios'; // Only on iOS!
7576

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));
8379
}
8480

8581
return badgeUpdate.then(() => {

0 commit comments

Comments
 (0)