开发者

"Pointers" in MongoDB?

开发者 https://www.devze.com 2023-03-17 23:19 出处:网络
In the project I am currently working on, it se开发者_如何学运维ems to make more sense efficiency wise if I create a nested document that contains a list of \"pointers\" to information stored in other

In the project I am currently working on, it se开发者_如何学运维ems 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!


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消