hi all, i search the dbref in mongodb group ,but find nothing help

83 views
Skip to first unread message

lemon

unread,
Apr 27, 2012, 1:42:43 AM4/27/12
to mongodb-user
here is my doc:
{"NAME" : "tom1", "CAR" : { "$ref" : "car ", "$id" :
ObjectId("4f9a0ee69a7224f86f74cc2d") } }
etc.... and ref there is follow:
{ "_id" : ObjectId("4f9a0ee69a7224f86f74cc2c"), "PRODUCER" : "benc" }
so if i want to know
1; how many people have a benc car
2; how many ref there is ,by the way ,how many producer there, like
distinct CAR.$id, but something like it didnot work
i can do it in Embedded way,but dont know how to do it in ref way in
java.
plz help

H.J

unread,
Apr 27, 2012, 3:56:04 AM4/27/12
to mongod...@googlegroups.com
An alternate method

http://pastebin.com/Nr7iWebp

2012/4/27 lemon <huwe...@gmail.com>:
> --
> 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.
>



--
尽人事,听天命!

lemon

unread,
Apr 27, 2012, 4:19:01 AM4/27/12
to mongodb-user
哈哈,here you again;
thanks , i have done it in that way
i just thought there may be some straight way like count method.

On 4月27日, 下午3时56分, "H.J" <shiyi...@gmail.com> wrote:
> An alternate method
>
> http://pastebin.com/Nr7iWebp
>
> 2012/4/27 lemon <huwei1...@gmail.com>:
>
>
>
>
>
>
>
>
>
> > here is my doc:
> > {"NAME" : "tom1",  "CAR" : { "$ref" : "car     ", "$id" :
> > ObjectId("4f9a0ee69a7224f86f74cc2d") } }
> > etc.... and ref there is follow:
> > { "_id" : ObjectId("4f9a0ee69a7224f86f74cc2c"), "PRODUCER" : "benc" }
> > so if i want to know
> > 1; how many people have a benc car
> > 2; how many ref there is ,by the way ,how many producer there, like
> > distinct CAR.$id, but something like it didnot work
> > i can do it in Embedded way,but dont know how to do it in ref way in
> > java.
> > plz help
>
> > --
> > You received this message because you are subscribed to the Google Groups "mongodb-user" group.> To post to this group, send email tomongo...@googlegroups.com.> To unsubscribe from this group, send email tomongodb-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages