Is it possible to define an object in your schema with unknown/dynamic keys? #428
-
Summary I'm working on a project where I want to store my data shaped like this example...
So instead of using an array or a separate model, the books are an object where they properties are the book names. I don't know what the keys of the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you don't know the key, you can use a generated ID and then fetch based on ID and filter on name. That works okay for a small number of books. A separate model is the way to go. If the book name is unique, use that in the key:
|
Beta Was this translation helpful? Give feedback.
If you don't know the key, you can use a generated ID and then fetch based on ID and filter on name. That works okay for a small number of books.
A separate model is the way to go. If the book name is unique, use that in the key: