mongoose - mongodb aggregate 找不到运算符
黄舟
黄舟 2017-04-24 09:11:18
0
1
647

完全不明白

db.users.aggregate(
       [
         {
           $group : {
             _id: { $sum: 1 }
           }
         }
       ]
     )
Error: Printing Stack Trace
    at printStackTrace (src/mongo/shell/utils.js:37:15)
    at DBCollection.aggregate (src/mongo/shell/collection.js:897:9)
    at (shell):1:10
Fri Sep 19 18:51:23.623 aggregate failed: {
    "errmsg" : "exception: invalid operator '$sum'",
    "code" : 15999,
    "ok" : 0
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

membalas semua(1)
迷茫

_id digunakan untuk GROUP Jika anda ingin menggunakan $sum, anda perlu menukar nama medan.

http://docs.mongodb.org/manual/reference/operator/aggregation/sum/#grp._S_sum

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan