2010-04-08 00:08:27 -04:00
|
|
|
|
2016-02-04 12:29:01 -05:00
|
|
|
t = db.pullall2;
|
|
|
|
|
t.drop();
|
2010-04-08 00:08:27 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
o = {
|
|
|
|
|
_id: 1,
|
|
|
|
|
a: []
|
|
|
|
|
};
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
|
o.a.push({x: i, y: i});
|
2010-04-08 00:08:27 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.insert(o);
|
2010-04-08 00:08:27 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(o, t.findOne(), "A");
|
2010-04-08 00:08:27 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.update({}, {$pull: {a: {x: 3}}});
|
|
|
|
|
o.a = o.a.filter(function(z) {
|
|
|
|
|
return z.x != 3;
|
|
|
|
|
});
|
|
|
|
|
assert.eq(o, t.findOne(), "B");
|
2010-04-08 00:08:27 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.update({}, {$pull: {a: {x: {$in: [1, 4]}}}});
|
|
|
|
|
o.a = o.a.filter(function(z) {
|
|
|
|
|
return z.x != 1;
|
|
|
|
|
});
|
|
|
|
|
o.a = o.a.filter(function(z) {
|
|
|
|
|
return z.x != 4;
|
|
|
|
|
});
|
|
|
|
|
assert.eq(o, t.findOne(), "C");
|