Skip to main content

Adding sub-models

Each model consists of various types of fields and also sub-models. To add a sub-model field to a model via the Designer, you need to Navigate to Models view and select the model that you would like to add the new sub-model field.

Model details view
info

Similar to models, Altogic automatically adds a system-managed object identifier field called "_id" to your sub-model definition. The identifiers assigned to each object of your model are unique and read-only, and they cannot be deleted, modified, or omitted.

Additionally, Altogic also adds a system-managed "_parent" field to your sub-model definition, referencing the parent model object. The _parent field is read-only and cannot be deleted.

info

As an example for a top-level "user" model, you can have a "profile" sub-model object where you put all user profile information like avatar, username, etc. Additionally, in a user model, you can also define the "addresses" sub-model object list where you can store all user addresses like home, work, etc.

To create a sub-model in Designer:

  1. Select New field
  2. From the dropdown menu, select either Object or Object list. If you select the object, then a single sub-model, and if you select the object list, then an array of sub-models will be added to your selected model
  3. In the field name, provide a unique name (case insensitive) to your new sub-model, and on the Object properties tab, enable/disable timestamps
  4. Select Create

You can also watch the following short tutorial on defining data hierarchies to get more practical information on how to add sub-models.