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.
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.