Skip to content

Commit 1bf32a6

Browse files
committed
Updates mongodb driver.remove() to use convertToDB
1 parent 2fef6a9 commit 1bf32a6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/Drivers/DML/mongodb.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ Driver.prototype.update = function (table, changes, conditions, cb) {
161161
};
162162

163163
Driver.prototype.remove = function (table, conditions, cb) {
164+
convertToDB(conditions);
165+
164166
return this.db.collection(table).remove(conditions, cb);
165167
};
166168

@@ -170,6 +172,17 @@ Driver.prototype.clear = function (table, cb) {
170172

171173
function convertToDB(obj) {
172174
for (var k in obj) {
175+
if (Array.isArray(obj[k])) {
176+
if (k == "_id") {
177+
for (var i = 0; i < obj[k].length; i++) {
178+
obj[k][i] = new mongodb.ObjectID(obj[k][i]);
179+
}
180+
}
181+
182+
obj[k] = { $in: obj[k] };
183+
continue;
184+
}
185+
173186
if (k == "_id") {
174187
obj[k] = new mongodb.ObjectID(obj[k]);
175188
}

0 commit comments

Comments
 (0)