Remove .rawCollection method from DatabaseController.
This commit is contained in:
@@ -64,6 +64,10 @@ export default class MongoCollection {
|
|||||||
return this._mongoCollection.update(query, update, { upsert: true });
|
return this._mongoCollection.update(query, update, { upsert: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateMany(query, update) {
|
||||||
|
return this._mongoCollection.updateMany(query, update);
|
||||||
|
}
|
||||||
|
|
||||||
// Atomically find and delete an object based on query.
|
// Atomically find and delete an object based on query.
|
||||||
// The result is the promise with an object that was in the database before deleting.
|
// The result is the promise with an object that was in the database before deleting.
|
||||||
// Postgres Note: Translates directly to `DELETE * FROM ... RETURNING *`, which will return data after delete is done.
|
// Postgres Note: Translates directly to `DELETE * FROM ... RETURNING *`, which will return data after delete is done.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ DatabaseController.prototype.collection = function(className) {
|
|||||||
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,
|
throw new Parse.Error(Parse.Error.INVALID_CLASS_NAME,
|
||||||
'invalid className: ' + className);
|
'invalid className: ' + className);
|
||||||
}
|
}
|
||||||
return this.rawCollection(className);
|
return this.adapter.collection(this.collectionPrefix + className);
|
||||||
};
|
};
|
||||||
|
|
||||||
DatabaseController.prototype.adaptiveCollection = function(className) {
|
DatabaseController.prototype.adaptiveCollection = function(className) {
|
||||||
@@ -46,10 +46,6 @@ DatabaseController.prototype.collectionExists = function(className) {
|
|||||||
return this.adapter.collectionExists(this.collectionPrefix + className);
|
return this.adapter.collectionExists(this.collectionPrefix + className);
|
||||||
};
|
};
|
||||||
|
|
||||||
DatabaseController.prototype.rawCollection = function(className) {
|
|
||||||
return this.adapter.collection(this.collectionPrefix + className);
|
|
||||||
};
|
|
||||||
|
|
||||||
DatabaseController.prototype.dropCollection = function(className) {
|
DatabaseController.prototype.dropCollection = function(className) {
|
||||||
return this.adapter.dropCollection(this.collectionPrefix + className);
|
return this.adapter.dropCollection(this.collectionPrefix + className);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -63,23 +63,19 @@ export class PushController extends AdaptableController {
|
|||||||
let badgeUpdate = Promise.resolve();
|
let badgeUpdate = Promise.resolve();
|
||||||
|
|
||||||
if (body.badge) {
|
if (body.badge) {
|
||||||
var op = {};
|
let op = {};
|
||||||
if (body.badge == "Increment") {
|
if (body.badge == "Increment") {
|
||||||
op = {'$inc': {'badge': 1}}
|
op = { $inc: { badge: 1 } }
|
||||||
} else if (Number(body.badge)) {
|
} else if (Number(body.badge)) {
|
||||||
op = {'$set': {'badge': body.badge } }
|
op = { $set: { badge: body.badge } }
|
||||||
} else {
|
} else {
|
||||||
throw "Invalid value for badge, expected number or 'Increment'";
|
throw "Invalid value for badge, expected number or 'Increment'";
|
||||||
}
|
}
|
||||||
let updateWhere = deepcopy(where);
|
let updateWhere = deepcopy(where);
|
||||||
|
updateWhere.deviceType = 'ios'; // Only on iOS!
|
||||||
|
|
||||||
// Only on iOS!
|
badgeUpdate = config.database.adaptiveCollection("_Installation")
|
||||||
updateWhere.deviceType = 'ios';
|
.then(coll => coll.updateMany(updateWhere, op));
|
||||||
|
|
||||||
// TODO: @nlutsenko replace with better thing
|
|
||||||
badgeUpdate = config.database.rawCollection("_Installation").then((coll) => {
|
|
||||||
return coll.update(updateWhere, op, { multi: true });
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return badgeUpdate.then(() => {
|
return badgeUpdate.then(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user