nobrainer icon indicating copy to clipboard operation
nobrainer copied to clipboard

Declare nested fields

Open sayuj opened this issue 5 years ago • 2 comments

I have a document like:

{
  "first_name": "First Name",
  "last_name": "Last Name",
  "birth": {
    "place": "Place of birth",
    "date": "Date of birth"
  }
}

I would like to declare the field birth["date"] as Date type. How can I do that?

sayuj avatar Mar 04 '20 11:03 sayuj

Nobrainer is not supporting this use case. From the roadmap:

Support embedded documents. Embedding should be done by using the type system like regular fields.

You can declare the birth field as a Hash but you can't control the data type within the hash.

There is another way of doing it, which is of using a Birth model and adding a has_one :birth to your current model. Then the Birth model can describe the fields and their types.

Hope this help :)

zedtux avatar Mar 13 '20 08:03 zedtux

@zedtux Thank you for your response.

Multiple documents would not be a perfect fit. I'm glad the use cases there on the roadmap.

sayuj avatar Mar 17 '20 03:03 sayuj