4

In the project I am currently working on, it seems to make more sense efficiency wise if I create a nested document that contains a list of "pointers" to information stored in other collections. That way this nested document can be easily used to retrieve a list of relevant information. The question is, how to do this? Is there a way to store locations of other information in a field in MongoDB? If not, could anyone suggest a scheme that is equally or more efficient? Thanks very much!

Community
  • 1
  • 1
Ben Kulbertis
  • 1,713
  • 4
  • 17
  • 30

1 Answers1

2

There is no GOOD way to do this. If this is what you're looking for, you should be using a relational database.

But if you HAVE to go by this route then, why not store ID's in a document, and then link those ID's to documents in the other collection.

Unfortunately, this would require you to do 2 separate queries, as Mongo does not support compound queries that span documents.

Dr. Xperience
  • 475
  • 1
  • 5
  • 18
ZacAttack
  • 2,005
  • 5
  • 21
  • 34