fetch data inside map/reduce

Showing 1-7 of 7 messages
fetch data inside map/reduce Martinus Martinus 4/29/12 7:32 PM
Hi,

Can I fetch data using DBRef inside map/reduce function?

Thanks.
Re: [mongodb-user] fetch data inside map/reduce Scott Hernandez 4/29/12 8:05 PM
No, not really.

Here is a better explanation and there are more if you go search
through the group/archives:
https://groups.google.com/group/mongodb-user/browse_thread/thread/b462b3e7b9a712b1
> --
> 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.
Re: [mongodb-user] fetch data inside map/reduce Martinus Martinus 4/29/12 8:25 PM
Hi Scott,

Thanks for your explanation. During the map phase I need to get documents from another collection which refer by the DBRef on my current collection where I do the map/reduce. Is there any other way to get this documents from another collection inside map/reduce function?

Thanks.
Re: [mongodb-user] fetch data inside map/reduce Scott Hernandez 4/29/12 8:46 PM
Are you just trying to group by those references? If so, can you look
them up when you query the results from the client?

In short, there are no joins at the server.

On Sun, Apr 29, 2012 at 8:25 PM, Martinus Martinus
Re: [mongodb-user] fetch data inside map/reduce Martinus Martinus 4/29/12 9:29 PM
Hi Scott,

For example I have this collection name animal :

{
     "_id" : 1,
     "type" : "dog",
     "animal_ref" : {
                "$ref" : "name",
                "$id" : ObjectId("4f9615bc0cf2f1a8f17cbb2a")
        }
}

and then I have another "name" collection :
{
     "_id" : 100,
     "food" : "dog_food",
     "quantity" : 10
}

So I do the map/reduce on animal collection, but I need the data from the name collection document (quantity and food) for each type of animal inside the animal collection.

Thanks.
Re: [mongodb-user] fetch data inside map/reduce Sammaye 4/30/12 12:24 AM
Is there any reason why you cant adjust your schema to match your MR?

So put a subdocument called "food" in the animal collection and place the "name" collection inside it.
Re: [mongodb-user] fetch data inside map/reduce Martinus Martinus 4/30/12 12:27 AM
Hi Sam,

Because the original "name" collection is not this small, it has many fields inside it. So that's why we put it into another collection.

Thanks.