mongoose - mongodb怎么实现一对多的功能。
高洛峰
高洛峰 2017-05-02 09:19:41
0
2
763

就是两个mongodb的表,或者是mongoose的表,然后要实现一对多的对应关系。怎么实现呢?可以举个例子吗?我找了很多文档,都没看懂。谢谢各位大神。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(2)
迷茫

I don’t know what you want, but one-to-many doesn’t seem to comply with database logic. For example, if you retrieve a field and the corresponding value is different, how does the program know which value to return to you?
But since you want to implement one-to-many in mongo, the key-value structure can achieve similar functions. You can set value as an array, so that one key can correspond to multiple values. The database returns an array, and you can find the results you want in the code.

淡淡烟草味

I don’t know what language the poster uses. Some mainstream development languages ​​have corresponding expansion packs.
For example, there is the Mongoid gem package in Ruby, which encapsulates many common methods and can easily meet your needs.
You can find out whether there is a corresponding library for the development language you are using.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template