Hello,
I have problem with understanding something or it's bugged.
Let's start. Here is documentation about DBRefs:
http://docs.mongodb.org/manual/reference/database-references/#dbrefs
They write that structure for document with reference should be:
{
"_id" : ObjectId("5126bbf64aed4daf9e2ab771"),
// .. application fields
"creator" : {
"$ref" : "creators",
"$id" : ObjectId("5126bc054aed4daf9e2ab772"),
"$db" : "users"
}
}
Now let's take a look on this example (example1):
https://gist.github.com/hastebrot/1170907
When I run this code I have something like that:
Story:
"title": "A man who cooked Nintendo",
"_creator": {
"$oid": "52e7dcea3d9cd59c13702e3d"
},
"_id": {
"$oid": "52e7dceb3d9cd59c13702e3e"
},
"fans": [],
"__v": 0
People:
"name": "Aaron",
"age": 100,
"_id": {
"$oid": "52e7dcea3d9cd59c13702e3d"
},
"stories": [],
"__v": 0
In our team we have small application written in Java which use library for MongoDB but this library save data like in MongoDB documentation:
....//other fields
"user": {
"$ref": "users",
"$id": {
"$oid": "52c6c497c08e6fcf37000001"
}
}
and I can't populate data because it seems like it works only for mongoose implementation.
Correct me if I'm wrong but for me it's like you not save DBRef like it's described in documentation.
+1
Facing the same issue with a php application using doctrine mongodb odm. Currently i cannot use my already existing db with mongoose because mongodb DBRefs objects are not use to store references.
Maybe a another schema type (Schema.DBRef ?) should be added ?
That would load the document with the given infos.
Still no input from any Mongoose dev on this issue? This is a recurring problem that keeps coming up when you have more than one driver writing to and reading from the same database.
The Node driver does support DBRefs and I find it odd that Mongoose still has no support for it.
Supporting DBRefs for populate isn't really a high priority because MongoDB docs recommend not using dbref. You can always do the queries yourself.
Most helpful comment
Still no input from any Mongoose dev on this issue? This is a recurring problem that keeps coming up when you have more than one driver writing to and reading from the same database.
The Node driver does support DBRefs and I find it odd that Mongoose still has no support for it.