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
3
votes
3 answers

mongodb query on DBRef type

How do I turn this query in a valid mongodb Query in mongodb shell. { 'cars.owner.$ref' : 'users' } cars.owner is a DBRef here, but $ref is invalid I get this error: "$err" : "Positional operator does not match the query specifier." My objective…
Willem D'Haeseleer
  • 19,661
  • 9
  • 66
  • 99
3
votes
1 answer

Get all usernames from a items user_id? (Mongodb query)

I am having some difficulty with my leaderboard for my application. I have a database with two collections. Users Fish In my Fish collection I also have user_id. When I fetch all fish, I get everything including user_id. However, the user_id…
Cheese Puffs
  • 955
  • 3
  • 10
  • 19
2
votes
0 answers

MongoDB Java - $push to List is overwriting existing entries

MongoDB Java - List update is causing existing entries to be overwritten. I have setup a 3 node mongo 4.0.27 replica set with 1 primary and 2 secondary nodes. I am executing a Push operation on a List to add new entries. However this is resulting in…
M Kumar
  • 21
  • 3
2
votes
1 answer

LiteDB Insert list with BsonRef

Hi and thanks in advance everyone! I have a collection of the following objects: public class ItemsModel { public List IdCollection { get; set; } public string Name { get; set; } public int Weight { get; set; } } List
awp-sirius
  • 59
  • 6
2
votes
1 answer

Morphia/Mongo not able to link @Reference, giving : The reference could not be fetched

I have set up a simple datastore to store a Version and a Build. Here are their classes- @Entity("Version") public class Version { @Id private ObjectId id = new ObjectId(); public Version() {} private String…
2
votes
0 answers

LiteDB query in 2 related Collections

I have a LiteDB database with 2 POCO classes Author that includes "Id" and "Name", as Properties Book that includes "Title" "Id" and "Author"(this property has a bson reference to the Author's collection) I'm trying to query the book collection…
cese01
  • 21
  • 2
2
votes
1 answer

Can't enumerate over objects with MongoDBRef

I have a collection called Products which I am trying to enumerate using the official mongo-csharp driver. However as soon as I try to enumerate the collection (e.g. with a foreach loop) I get the following error. "Default constructor not found for…
Alex
  • 34,776
  • 10
  • 53
  • 68
2
votes
1 answer

Spring data and mongoDB - inheritance and @DBRef

I have this two documents, User: @Document(collection = "User") public class User { // fields } and Contact: @Document(collection = "Contact") public class Contact extends User{ // fields } and then I have a document which referes either…
quma
  • 5,233
  • 26
  • 80
  • 146
2
votes
0 answers

build find and count queries with MongoRepository when dao use DBRef with Map

Whats the name of "count" and "find" queries when i use DBRef in conjunction with java.util.map? In my example the countByFoos-Method always returns 0 instead of 1. How can i find and count BarDaos by given FooDao? public class FooDao { @Id …
Ultimate Fighter
  • 1,787
  • 2
  • 10
  • 12
2
votes
1 answer

delete dbref element from another collection

I have a collection session which contains elements { "_id" : NumberLong(1), "_class" : "cws.CWSession", "title" : "java ", "description" : "apprendre à programmer en java" } { "_id" : NumberLong(2), "_class" :…
Alyssa
  • 109
  • 12
2
votes
0 answers

How can one "join" a DBRef

Somehow it must be possbile to generate a result when DBReferences are resolved and the value of the referenced object is given back together whit the original object. example: first object has a reference { "_id" :…
Roland Kofler
  • 1,332
  • 1
  • 16
  • 33
2
votes
0 answers

Spring Data MongoDB + QueryDSL + DBRef = Exception

My Setup: mongo-java-driver 2.11.3 spring-data-mongodb 1.4.0.M1 spring-data-commons 1.7.0.M1 querydsl-mongodb 3.3.0 spring 4.0.0.RELEASE java 1.7 MongoDB v2.4.8 User.java: @Document(collection="user") public class User { public User(String…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
2
votes
2 answers

How to find records by foreign key (dbref) in morphia and mongodb?

I have following entity: class Linf { @Id ObjectId id; @Reference Denied denied; } I want to find all Linfs that have Denied object with certain id. How can I do this? Will this query employ indexes? I want to avoid full scan if…
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
2
votes
0 answers

How to change DBRef for MongoDB?

So, I'm using MongoDB for a project an I have a server that was used to do all the testing for my site and I used DBRef on a few tables and this created something like this: "comment": { "$ref": "user", "$id": ObjectId("xxxx"), "$db":…
2
votes
1 answer

DBRefs vs Map/Reduce vs Manual References

I've come across three different ways of "joining" collections: Manually keep a "foreign-key-esk" reference to the collection you wish to join with your target collection Use DBRefs Write a series of Map/Reduce functions to maintain the…
Adam
  • 3,063
  • 5
  • 35
  • 49