Querying size of an array inside a document on the server - without client loading the document

55 views
Skip to first unread message

Rick Welykochy

unread,
Nov 25, 2011, 6:03:40 PM11/25/11
to mongod...@googlegroups.com
Hi all,

Refering to stockoverflow:

http://stackoverflow.com/questions/6722850/querying-internal-array-size-in-mongodb

Consider a MongoDB document in users collection:

{ username : 'Alex', tags: ['C#', 'Java', 'C++'] }

Is there any way, to get the length of the tags array from the server
side (without passing the tags to the client) ?

The answer seems to be a resounding NO. Is that correct?

Aside: how does one do SQL-ish things like AVG(column), MAX(column)?
If map/reduce is the answer, then perhaps map/reduce is the answer to
discovering the length of an array in a document.


regards,
rickw


--
_________________________________
Rick Welykochy || Praxis Services

If the English language made any sense, 'lackadaisical' would have
something to do with lack of flowers.
-- Doug Larson

Eliot Horowitz

unread,
Nov 26, 2011, 9:46:30 AM11/26/11
to mongod...@googlegroups.com
There isn't a way to do that currently - would be a good thing to add
a feature request for @ http://jira.mongodb.org/

See http://www.mongodb.org/display/DOCS/Aggregation for aggregation options.

> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.
>
>

Aristarkh Zagorodnikov

unread,
Nov 27, 2011, 3:07:43 AM11/27/11
to mongodb-user
Hello,

As we need the same functionality, I considered it would be fine if I
add the request myself: https://jira.mongodb.org/browse/SERVER-4376.

Thanks for your attention,
Aristarkh Zagorodnikov

On 26 ноя, 18:46, Eliot Horowitz <el...@10gen.com> wrote:
> There isn't a way to do that currently - would be a good thing to add
> a feature request for @http://jira.mongodb.org/
>

> Seehttp://www.mongodb.org/display/DOCS/Aggregationfor aggregation options.


>
> On Fri, Nov 25, 2011 at 6:03 PM, Rick Welykochy
>
>
>
> <rick.welyko...@gmail.com> wrote:
> > Hi all,
>
> > Refering to stockoverflow:
>

> >http://stackoverflow.com/questions/6722850/querying-internal-array-si...


>
> >  Consider a MongoDB document in users collection:
>
> >  { username : 'Alex', tags: ['C#', 'Java', 'C++'] }
>
> >  Is there any way, to get the length of the tags array from the server
> >  side (without passing the tags to the client) ?
>
> > The answer seems to be a resounding NO. Is that correct?
>
> > Aside: how does one do SQL-ish things like AVG(column), MAX(column)?
> > If map/reduce is the answer, then perhaps map/reduce is the answer to
> > discovering the length of an array in a document.
>
> > regards,
> > rickw
>
> > --
> > _________________________________
> > Rick Welykochy || Praxis Services
>
> > If the English language made any sense, 'lackadaisical' would have
> > something to do with lack of flowers.
> >     -- Doug Larson
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "mongodb-user" group.
> > To post to this group, send email to mongod...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > mongodb-user...@googlegroups.com.
> > For more options, visit this group at

> >http://groups.google.com/group/mongodb-user?hl=en.- Скрыть цитируемый текст -
>
> - Показать цитируемый текст -

Reply all
Reply to author
Forward
0 new messages