Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id" : 1,
- "item" : "ABC1",
- "description" : "product 1",
- "test" : {
- "colors" : [
- "blue",
- "black",
- "red"
- ]
- }
- }
- db.getCollection('mycollection').aggregate(
- [
- {
- $project: {
- numberOfColors: { $size: "test.$colors" }
- }
- }
- ]
- )
- Failed to execute script.
- Error:
- Assert: command failed: {
- "ok" : 0,
- "errmsg" : "The argument to $size must be an Array, but was of type: String",
- "code" : 17124
- } : aggregate failed
- _getErrorWithCode@src/mongo/shell/utils.js:23:13
- doassert@src/mongo/shell/assert.js:13:14
- assert.commandWorked@src/mongo/shell/assert.js:266:5
- DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
- @(shell):1:1
- Error: command failed: {
- "ok" : 0,
- "errmsg" : "The argument to $size must be an Array, but was of type: String",
- "code" : 17124
- } : aggregate failed :
- _getErrorWithCode@src/mongo/shell/utils.js:23:13
- doassert@src/mongo/shell/assert.js:13:14
- assert.commandWorked@src/mongo/shell/assert.js:266:5
- DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
- @(shell):1:1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement