Advertisement
Guest User

Untitled

a guest
Apr 13th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. {
  2. "_id" : 1,
  3. "item" : "ABC1",
  4. "description" : "product 1",
  5. "test" : {
  6. "colors" : [
  7. "blue",
  8. "black",
  9. "red"
  10. ]
  11. }
  12. }
  13.  
  14. db.getCollection('mycollection').aggregate(
  15. [
  16. {
  17. $project: {
  18. numberOfColors: { $size: "test.$colors" }
  19. }
  20. }
  21. ]
  22. )
  23.  
  24. Failed to execute script.
  25.  
  26. Error:
  27. Assert: command failed: {
  28. "ok" : 0,
  29. "errmsg" : "The argument to $size must be an Array, but was of type: String",
  30. "code" : 17124
  31. } : aggregate failed
  32. _getErrorWithCode@src/mongo/shell/utils.js:23:13
  33. doassert@src/mongo/shell/assert.js:13:14
  34. assert.commandWorked@src/mongo/shell/assert.js:266:5
  35. DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
  36. @(shell):1:1
  37.  
  38. Error: command failed: {
  39. "ok" : 0,
  40. "errmsg" : "The argument to $size must be an Array, but was of type: String",
  41. "code" : 17124
  42. } : aggregate failed :
  43. _getErrorWithCode@src/mongo/shell/utils.js:23:13
  44. doassert@src/mongo/shell/assert.js:13:14
  45. assert.commandWorked@src/mongo/shell/assert.js:266:5
  46. DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1215:5
  47. @(shell):1:1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement