{ "_comment": [ "Inputs only. Expectations are measured -- see record.js.", "`$push`'s modifiers: `$each`, `$slice`, `$position`, `$sort`. This server", "already implements `$push` and `$each` and *silently ignores* the other", "three -- `{$each: [3, 4], $slice: -3}` appended and did not slice, and", "answered ok: 1. That is the same class of wrong answer the positional", "operators were: the client asked for one thing and was told it got it." ], "documents": [{ "_id": 1, "t": [1, 2] }], "cases": [ { "description": "$slice keeps the last n", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3, 4], "$slice": -3 } } } } }, { "description": "$slice keeps the first n", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3, 4], "$slice": 3 } } } } }, { "description": "$slice of zero empties the array", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3], "$slice": 0 } } } } }, { "description": "$slice larger than the array keeps all of it", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3], "$slice": 10 } } } } }, { "description": "$slice with an empty $each truncates without adding", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [], "$slice": 1 } } } } }, { "description": "$position inserts at the front", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [9], "$position": 0 } } } } }, { "description": "$position inserts in the middle", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [9], "$position": 1 } } } } }, { "description": "$position past the end appends", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [9], "$position": 99 } } } } }, { "description": "$position counted from the end", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [9], "$position": -1 } } } } }, { "description": "$sort ascending over scalars", "documents": [{ "_id": 1, "t": [3, 1] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [2], "$sort": 1 } } } } }, { "description": "$sort descending over scalars", "documents": [{ "_id": 1, "t": [3, 1] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [2], "$sort": -1 } } } } }, { "description": "$sort on a field of the elements", "documents": [{ "_id": 1, "t": [{ "a": 3 }, { "a": 1 }] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [{ "a": 2 }], "$sort": { "a": 1 } } } } } }, { "description": "$sort and $slice together", "documents": [{ "_id": 1, "t": [3, 1] }], "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [2], "$sort": 1, "$slice": 2 } } } } }, { "description": "$position and $slice together", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [9], "$position": 0, "$slice": 2 } } } } }, { "description": "$slice without $each", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$slice": 1 } } } } }, { "description": "$each that is not an array", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": 3 } } } } }, { "description": "$slice that is not a number", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3], "$slice": "x" } } } } }, { "description": "$position that is not a number", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3], "$position": "x" } } } } }, { "description": "an unknown modifier beside $each", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "$each": [3], "$bogus": 1 } } } } }, { "description": "a document operand that is not modifiers at all is a value", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "t": { "a": 1 } } } } }, { "description": "$push $each onto a missing field", "operation": "updateOne", "arguments": { "filter": {}, "update": { "$push": { "gone": { "$each": [1, 2] } } } } } ] }