how do .group()?

Visto 3.464 veces
Saltar al primer mensaje no leído

AbS_

no leída,
3 mar 2011, 17:34:513/3/11
a Mongoose Node.JS ORM
Hi,
How i can do something like this:
db.posts.group({key: {region:true}, $reduce: function(){}, initial:
{}})

on Mongoose?

Marc Harter

no leída,
26 mar 2011, 23:35:4926/3/11
a mongoo...@googlegroups.com,AbS_
I have the same question.  This possible, digging into the docs and code base couldn't find anything.  My gut is just do separate queries for each 'group'.  Can anyone shine some light on this?

Jeroen Bourgois

no leída,
8 abr 2011, 3:44:498/4/11
a Mongoose Node.JS ORM
Yes, I would need it to. Any updates on how to achieve this? Makes a
big difference if you have to get +5000 documents from the db, filter
them in your app and do the grouping yourself. Really slow :(

Jeroen Bourgois

no leída,
10 abr 2011, 16:11:5410/4/11
a Mongoose Node.JS ORM
Got it!

Model.find({}, [fields], {'group': 'FIELD'}, function(err, logs) {
...
});

Florian Pfitzer

no leída,
4 jun 2011, 8:21:024/6/11
a Mongoose Node.JS ORM
Is this still working with 1.3.7?

I have list of People and I want them to be grouped by lastname, so i
did:

People.find({},[],{'group': 'lastname'},function(err,people){
...
});

But it returns the same like:

People.find({},function(err,people){
...
});

and there is no error.

Láďa Říha

no leída,
4 mar 2012, 11:38:004/3/12
a mongoo...@googlegroups.com
Bump... Has anyone achive that in version 2.5.x?

一回

no leída,
14 mar 2012, 10:05:0214/3/12
a Mongoose Node.JS ORM
you can use this:

Model.collection.group(keys, condition, initial, reduce, finalize,
command, callback);
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos