Sono provo ottenere dati da collezione con un certo ordine:
db.data.aggregate([
{$limit: 1000},
{$group: {
_id: "$service",
count: {$sum: 1},
data: {$push: '$$ROOT'}
}}
]);
Ma ottenere prossimo errore:
Error("Printing Stack Trace")@:0
()@src/mongo/shell/utils.js:37
([object Array])@src/mongo/shell/collection.js:866
@(shell):6
uncaught exception: aggregate failed: {
"errmsg" : "exception: FieldPath field names may not start with '$'.",
"code" : 16410,
"ok" : 0
}
Dove ho sbagliato?
Stai effettivamente utilizzando una versione 2.6? È stato appena rilasciato e quindi la documentazione ora riflette la versione più recente. –