cfmongodb aggregate() function question

23 views
Skip to first unread message

Matt Tew

unread,
Mar 16, 2015, 9:22:07 PM3/16/15
to cfmo...@googlegroups.com
I tried to use the aggregate function in cfmongodb with no luck. Hopefully someone can help me out here.

Basically I just want to return a simple query where return any Authors has more than 2 books:
In MongoDB shell:

db.Book.aggregate([{$group:{_id:"$AUTHOR", count:{$sum:1}}}, {$match:{count:{$gt:1}}}]);


Tried in Coldfusion:
local.collection is the Book collection.

local.collection.aggregate(

{ "$group"={ "_id"="$AUTHOR", "count"={ "$sum"=1} } },

{ "$match"={ "count"={"$gt"=1} } }

).asArray();

If I remove the $match query, it will return me the count with zero.

I'm sure I missing somethign here since this is simple query, but what is it?

Thanks in advance!

Marc Esher

unread,
Mar 16, 2015, 9:32:28 PM3/16/15
to cfmo...@googlegroups.com
Matt, first off, can you run examples/gettingstarted.cfm on your
machine successfully? Does examples/aggregation/aggregate.cfm work as
well?

Second, what version of MongoDB and ColdFusion are you running?

We need to narrow down to:

1. Problem with your environment
2. Problem with your query
3. Problem with cfmongodb
4. Problem with all of these and whatever version of mongo you're running
> --
> You received this message because you are subscribed to the Google Groups
> "CFMongoDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cfmongodb+...@googlegroups.com.
> To post to this group, send email to cfmo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cfmongodb.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages