Getting a distinct aggregation of an array field across indexes

后端 未结 5 1528
[愿得一人]
[愿得一人] 2020-12-03 03:10

I\'m trying to learn MongoDB and how it\'d be useful for analytics for me. I\'m simply playing around with the JavaScript console available on their website and have created

5条回答
  •  不思量自难忘°
    2020-12-03 03:55

    The code that fails on their website works on an actual MongoDB instance:

    > db.posts.insert({title: "Hello", tags: ["one", "five"]});
    > db.posts.insert({title: "World", tags: ["one", "three"]});
    > db.posts.distinct("tags");
    [ "one", "three", "five"]
    

    Weird.

提交回复
热议问题