Questions tagged [dbref]

mongodb - Database references

DBRefs (MongoDB) are references from one document to another using the value of the first document’s _id field, collection name, and, optionally, its database name. By including these names, DBRefs allow documents located in multiple collections to be more easily linked with documents from a single collection. (Database references[MongoDB])

117 questions
2
votes
1 answer

get dbref from document in Mongo using Java

I cannot get dbRef object from Mongo. In my entity package I have a User class with a Parent class inheriting. Here is the User class: public class User { @Id private ObjectId id; @DBRef private Account account; private String name; public…
boburShox
  • 2,630
  • 5
  • 23
  • 35
2
votes
1 answer

Symfony2 DoctrineMongoDBBundle one-to-many Bi-Directional References

I'm trying to use relations in MongoDB, using Symfony2 and DoctrineMongoDBBundle According slide 49 of the Doctrine MongoDB Object Document Mapper presentation, it's enough to assign $User->setOrganization($Organization), to make…
karser
  • 1,625
  • 2
  • 20
  • 24
1
vote
3 answers

Find orhphaned DBRef in collection

Is there any easy way to find orphaned references in query? I've got a collection of elements having parent reference. After some parents was removed I'd like to search elements that pointed to them, i.e. those that have hanging references. I tried…
Mike M.
  • 11
  • 1
  • 2
1
vote
1 answer

MongoDB - DB Reference returns null value

As seen in this image when I try to retrieve address details from collection 'address_home' using DB Reference in MongoDB, it returns null value. Anybody know what is the problem with this code? I tried the code in the image. I want it to print…
VX7
  • 23
  • 5
1
vote
1 answer

How to handle mongodb relation modeling with webflux?

I have an old-ish (3 years) service I need to maintain and just joined the team. It is a spring-webflux app with mongodb (4). All models are defined with lombok and where there are relations between them, @DBRef annotation was used. It works fine,…
dcg
  • 1,144
  • 1
  • 22
  • 38
1
vote
1 answer

mongodb for each document retrieve its fields + count of its id in another collection by reference

Lets say I have a user collection where a single document has fields like this { "_id" : "4775222e-8e4f-4f84-8dba-b097291bbd39", "surname" : "Smith", "forename" : "John" } and lets say I have jobs collection where a document has some…
tibortru
  • 692
  • 5
  • 26
1
vote
1 answer

Mongo Lookup with nested DBRefs

I have a collection in MongoDB called 'post' with a list of DBRefs to 'author' which in turn has DBRef to a collection 'media'. When I retrieve posts, I would like to get the entire object for post including all authors and media within the…
Shashi Deshetti
  • 1,354
  • 2
  • 11
  • 22
1
vote
0 answers

Spring data mongodb DbRef cache

I have a query that fetches 10k documents and every document has a dbref to another document. This query takes ~5 seconds to run and is unacceptable. During debug and logging i've spotted that mongo driver makes a round trip to database for every…
aleshka-batman
  • 187
  • 1
  • 13
1
vote
1 answer

MongoDB 3.4 MongoDBRef dereferencing with .NET MongoDB Driver

I have following collections: Collection A { "_id" : ObjectId("5aaa3b170e26ed1eba223ba9"), "name" : "A1", "ref" : { "$ref" : "B", "$id" : ObjectId("5aaa33740e26ed1eba223ba1") } } { "_id" :…
ahux
  • 41
  • 5
1
vote
1 answer

How to add a BsonDocument with a MongoDBRef in

I try to add document with C# on my MongoDB database. I want to add those documents with a DBRef in. Like this : MongoCompass Screen Now, I add documents like this : var client = new MongoClient("mongodb://10.194.157.199:27017"); …
1
vote
1 answer

DBRefs In MongoDB

I am able to add first degree relation to one collection to another but not able to add DBRefs if the collection has any internal structure (document). For an example, I want to link tour_id in suggested_place internal structure to o_id of…
Rohit Kumar
  • 877
  • 6
  • 20
1
vote
2 answers

How to count distinct values of a reference collection in mongo

Having a list of books that points to a list of authors, I want to display a tree, having in each node the author name and the number of books he wrote. Initially, I have embedded the authors[] array directly into books collection, and this worked…
hypercube
  • 958
  • 2
  • 16
  • 34
1
vote
1 answer

Spring Data - MongoDB: Unable to retrieve DBRef document that belongs to another database

I have a Entity Market(market is stored in a collection within marketDb database) that references Product (stored in a collection product in productDb database ). /*Entity */ class Market { @DBRef (db = "productDb") private Product…
1
vote
0 answers

Querying using two-way referencing in MongoDB

I have two classes: class Person { @DBRef @JsonManagedReference private List tasks; } class Task { @DBRef @JsonBackReference private Person person; } When I query to find all Persons the list of Tasks is populated with the…
Lucas Beier
  • 621
  • 1
  • 7
  • 19
1
vote
1 answer

Spring application design when using two-way referencing in Mongo

I have two classes Person and Tasks. It's one-to-many relationship: a Person has a list of Tasks and a Task belongs to a Person. My application has two views. In one of them I need to show the Persons and the Tasks associate to each Person. In the…
Lucas Beier
  • 621
  • 1
  • 7
  • 19