morphia icon indicating copy to clipboard operation
morphia copied to clipboard

@Reference DBRef should include $db

Open rbento opened this issue 11 years ago • 3 comments

Hello my friends, keep up the awesome work!

Please, take a look that this issue and proposed solution in the link. Could it be fixed?

https://code.google.com/p/morphia/issues/detail?id=233

Being brief about this, storing the $db would save a lot of work when dealing with cases of a createdBy field reference a user from another db. Say the admin is from default domain, if he creates a user in domaina, dbref should store the db so a user from defaultdomain can be referenced in a users collection from db domaina.

In short its this structure:

defaultdomain users

domaina users

domainb users

I hope it is possible. Thanks a lot.

rbento avatar Mar 07 '13 09:03 rbento

something tells me the Key object will need to be modified to carry a ref to the db name or obejct to accomplish this, it also assumes your using 2 distinct datastore instances. you should also reallly check to see if you need a seperate db ust for a single collection.

washu avatar Mar 10 '13 22:03 washu

The separate dbs are due to application logic, but the DBRefs storing the $db reference is already available in mongodb interface, just not available via Morphia. Please take a look: http://api.mongodb.org/java/current/com/mongodb/DBRef.html

rbento avatar Mar 11 '13 00:03 rbento

ill look over this while im traveling this week, gives me something todo while wait for connection flights

washu avatar Mar 19 '13 21:03 washu