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
1
vote
1 answer

Denormalization vs Parent Referencing vs MapReduce

I have a highly normalized data model with me. Currently I'm using manual referencing by storing the _id and running sequential queries to fetch details from the deepest collection. The referencing is one-way and the flow has around 5-6 collections.…
Soumojit Ghosh
  • 921
  • 7
  • 16
1
vote
2 answers

MongoDB DBReference how to?

i'm learning MongoDB and i have the next questions. There are my MongoDB documents This is coordenada document > db.coordenada.find().pretty() { "_id" : ObjectId("5579b81342a31549b67ad00c"), "longitud" : "21.878382", …
Amaury Esparza
  • 1,028
  • 2
  • 12
  • 18
1
vote
1 answer

Check if User object exists in @DBRef List

I'm making use of MongoDB, Spring Data and Spring MVC. I have a user model which has a list of contacts: class User { @DBRef private List contacts = new ArrayList(); public List getContacts() { return contacts; } } I…
Moody
  • 851
  • 2
  • 9
  • 23
1
vote
1 answer

Differences between ActiveRecord and Repository when generating JPA entity from a database schema using Spring Roo?

As Spring Roo guide here to do DBRE on a schema, we have the below command to generate the entities and theirs related files. We there can choose between taking the argument --activerecord or --repository; choosing the later will ignore the…
Nam G VU
  • 33,193
  • 69
  • 233
  • 372
1
vote
1 answer

MongoDB Shard considering DBRefs

I have a case where in first collection I use DBRef to another collection. First collection is Books, the second is Users (who read those books). The user can have avatars and various other informations, which is reasonable to keep in separate…
1
vote
2 answers

Query other attribute in MongoDB with DBRef

I have two tables' structure in mongodb: > db.mapping.find() { "_id" : ObjectId("52d74f4941538c0b386090af"), "tc" : DBRef("fttc", ObjectId("52d74f4841538c0b3860902e")), "hit" : { "24" : 1, "25" : 1, "26" : 1, "27" : 2}} ... > db.fttc.find() {…
Gallery
  • 268
  • 4
  • 14
1
vote
1 answer

MongoTemplate how to include specific fields of DBref

Hi I have structure called problem which internally has chapter, chapter has DBref to BookEdition and BookEdition has DBRef to Book Problem { String name, @DBRef Chapter chapter; } Chapter { String name, @DBRef BookEdition…
plzdontkillme
  • 1,497
  • 3
  • 20
  • 38
1
vote
1 answer

Pass DBRef in mongo query while fetching a document using java

db.collectionB.findOne() { "_id" : NumberLong(24), "class" : "Top", "type" : DBRef("collectionA", NumberLong(47)) } db.collectionA.findOne() { "_id" : NumberLong(47), "name" : "John", "position" : 2 } QUERY to be formed :…
SET
  • 55
  • 1
  • 5
1
vote
1 answer

reference value of map type field in mongo using spring data (dbref)

I have a map field in my document (key = content type, value = content) where I want the value part(content, which is another document) to be saved in mongodb as a referenced object. private Map relatedContents; For example,…
shailesh
  • 763
  • 2
  • 9
  • 23
1
vote
1 answer

Querying mongodb dbref inner field

I need to hide all the user related data whose isActive flag is set to false. There are many collection in which I have used user collection as of type DBRef (around 14 collections) and each collection contains more than 10 million records. Let me…
mobizen
  • 483
  • 8
  • 20
1
vote
1 answer

Query a collection with DBRef

I have 2 entities as following: @Document public class Freelancer { @Id String id; String name; @DbRef List bidProjects; } @Document public class Project { @Id String id; String name; } Project can't have the ref to freelancer as…
Rakesh Sinha
  • 19
  • 1
  • 6
1
vote
1 answer

Mongo dbref additional fields are invisible in mongoshell. How to display them?

Background: This problem came up with Doctrine ODM, that uses a _doctrine_class_name field in DBRefs that is invisible in the Mongo shell (2.2.2) and caused quite a culprit, when we had to update a record manually. Example: mongoshell> use testdb;…
Andor
  • 5,523
  • 5
  • 26
  • 24
1
vote
1 answer

Mongoose DBRef remove original schema removal to remove DBRefs and pull out from DBRef Array

In Mongoose, I can declare Schemas and also I can use DBRef which is simply putting ObjectId or an Array of ObjectId and populate(get) those items. I think it would be problem when a DBRef removal is needed. Is there any way to possibly sync removal…
jwchang
  • 10,584
  • 15
  • 58
  • 89
0
votes
1 answer

MongoDB - DBRef

I am having some troubles with DBRef, look this case: db.fruit.save ({"_id" : "1" , "name" : "apple"}); db.fruit.save ({"_id" : "2" , "name" : "grape"}); db.fruit.save ({"_id" : "3" , "name" : "orange"}); db.fruit.save ({"_id" : "4" , "name" :…
Caio
  • 3,178
  • 6
  • 37
  • 52
0
votes
0 answers

Spring Boot + MongoDB - How to use DBRef?

I have a collection of User objects, that have a collection of friends, that are... User objects. I want to map that in Spring Boot, so I made a Model class, a Service, a Controller, you name it... Here is my model class : @Document(collection =…