Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id" : ObjectId("58760d8caa30c585ef8d3beb"),
- "results" : [
- {
- "item" : "A",
- "score" : 5.0,
- "answers" : [
- {
- "q" : 1.0,
- "a" : 4.0
- },
- {
- "q" : 1.0,
- "a" : 5.0
- },
- {
- "q" : 2.0,
- "a" : 6.0
- }
- ]
- },
- {
- "item" : "B",
- "score" : 8.0,
- "answers" : [
- {
- "q" : 1.0,
- "a" : 7.0
- },
- {
- "q" : 1.0,
- "a" : 5.0
- },
- {
- "q" : 2.0,
- "a" : 9.0
- }
- ]
- }
- ]
- }
- {
- "_id" : ObjectId("58760d8caa30c585ef8d3beb"),
- "results" : [
- {
- "item" : "A",
- "score" : 5.0,
- "answers" : [
- {
- "q" : 2.0,
- "a" : 6.0
- }
- ]
- },
- {
- "item" : "B",
- "score" : 8.0,
- "answers" : [
- {
- "q" : 2.0,
- "a" : 9.0
- }
- ]
- }
- ]
- }
- db.getCollection('test').update({"results.answers.q":1},
- { $pull: {"results.$.answers": {q:1} } },
- { multi: true })
- {
- "_id" : ObjectId("58760d8caa30c585ef8d3beb"),
- "results" : [
- {
- "item" : "A",
- "score" : 5.0,
- "answers" : [
- {
- "q" : 2.0,
- "a" : 6.0
- }
- ]
- },
- {
- "item" : "B",
- "score" : 8.0,
- "answers" : [
- {
- "q" : 1.0,
- "a" : 7.0
- },
- {
- "q" : 1.0,
- "a" : 5.0
- },
- {
- "q" : 2.0,
- "a" : 9.0
- }
- ]
- }
- ]
- }
- db.getCollection('test').update({},{ $pull: {"results":{"answers": {$elemMatch:{q:1} }} }},{ multi: true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement