meteor-astronomy
meteor-astronomy copied to clipboard
Embedded Objects
I have been using Astronomy to deal with validation and behavior of models, and it has been very helpful. However, I am having trouble understanding how to implement embedded objects, and the documentation is somewhat sparse on this topic.
Specifically, I would like to have embedded objects whose fields could be validated against a schema and have "helper" functions, and an embedded object within that embedded object (also with validation and helpers). Essentially, they could function similar to classes created using Class.create, but would not have their own collections. For example:
A Book Model, with fields: Name (String), Author (String), and Pages (Embedded objects). Pages would have the fields: Page Number (Number), Color (String), and Sections (Embedded Objects). And Sections would have the fields: Corner (String), Body (String).
Both Pages and Sections could have helper functions, such as page.clearAllSectionBodies() and section.exportBodyToExcel().
I have been trying to use custom Types (Type.create), but I am having trouble making it perform this way. Is this the proper way to implement something like this?
Thank you.
You should start from taking a look at the example repository here https://github.com/jagi/meteor-astronomy-examples. It should answer all your questions. Let me know if it helps
That was exactly what I was looking for. Thank you pointing me in the right direction.