I get this error message(“The field ‘count’ must be an accumulator object”, ), on lab 1, and I still cannot see what is wrong with the code. Please kindly help…!!
MongoDB Enterprise atlas-o1jdjg-shard-0:PRIMARY> db.listingsAndReviews.aggregate([ {"$project": {"room_type":1, "_id":0}}, {"$group": {"_id": "$room_type"}} ]).pretty()
MongoDB Enterprise atlas-o1jdjg-shard-0:PRIMARY>
MongoDB Enterprise atlas-o1jdjg-shard-0:PRIMARY>
MongoDB Enterprise atlas-o1jdjg-shard-0:PRIMARY> **db.listingsAndReviews.aggregate([**
**... {"$project": {"room_type":1, "_id":0}},**
**... {"$group": {"_id": "room_type", "count":{"sum":1}}}**
**... ]).pretty()**
2022-01-24T05:15:01.353+0000 E QUERY [js] Error: command failed: {
"operationTime" : Timestamp(1643001301, 7),
"ok" : 0,
"errmsg" : "The field 'count' must be an accumulator object",
"code" : 40234,
"codeName" : "Location40234",
"$clusterTime" : {
"clusterTime" : Timestamp(1643001301, 7),
"signature" : {
"hash" : BinData(0,"PJNZrRUuC/BKQjlFv6tNRK5f5iw="),
"keyId" : NumberLong("6990363765946449922")
}
}
} : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:534:17
assert.commandWorked@src/mongo/shell/assert.js:618:16
DB.prototype._runAggregate@src/mongo/shell/db.js:260:9
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1062:12
@(shell):1:1
MongoDB Enterprise atlas-o1jdjg-shard-0:PRIMARY>