Is it possible to query through a DBRef using a single find spec?
user collection
{
'age': 30
}
post collection
{
'user': DBRef('user', ...)
}
Is it possible to query for all post who's users are 30 in a single find step? If not, would it be wise to create a javascript function to handle the multi-stage operation or will ...
I've encountered several situations when using MongoDB that require the use of DBRefs. However, I'd also like to cache some fields from the referenced document in the DBRef itself.
{$ref:'user', $id:'10285102912A', username:'Soviut'}
For example, I may want to have the username available even though the user document is referenced. ...
I want to create a DBRef manually so that I can add an additional field to it. However, when I try to pass the following:
{'$ref': 'projects', '$id': '1029412409721', 'project_name': 'My Project'}
Pymongo raises an error:
pymongo.errors.InvalidName: key '$id' must not start with '$'
It would seem that pymongo reserve the $ for the...
Is there a way in MongoDB to have a foreign key with a 'ON DELETE CASCADE' functionality?
I know you can use DBRef as a sort of foreign key but when the item in a collection where the reference points to is removed, the reference returns null. But i want that the item where the reference belongs to gets removed. How do i do this?
Or do...