Skip to main content

Creating a model

To create a model via the Designer, you have two options. Either you can create a model from scratch or from a sample JSON document. In either case, first, you need to navigate to the Models view in designer and either select + or New model.

Models view in Designer
info

When an object is created, Altogic automatically adds a system-managed object identifier field called "_id" to your model definition. The identifiers assigned to each object of your model are unique and read-only, and the system-managed identifier fields cannot be deleted or modified.

Creating a model from scratch

To create a new model via the Designer:

  1. Select New Model
  2. From the dropdown menu, select From scratch
  3. In the model name, provide a unique name (case insensitive) to your new model, select model group, specify whether the model is permanent or transient and enable/disable timestamps
  4. Select Next if you are creating a permanent model or Create if you are creating a transient model
  5. The default CRUD endpoints of your new model are displayed if you are creating a permanent model. Uncheck the ones that you do not want to be created and modify the endpoint paths if needed.
  6. Select Create
Create model from scratch
info

Altogic can automatically create the default CRUD (create, read, update and delete) endpoints and associated services for your permanent models. Automatic creation of these default endpoints and services can significantly speed up your development.

For each permanent model, Altogic can create the following endpoints and services:

  • Create a new model object
  • Get a model object by id
  • Update an existing model object by id
  • Delete an existing model object by id
  • Get a list of model objects paginated by page number, page size and sorted by a sort criteria

Creating a model from a sample JSON document

To create a model from a JSON document via the Designer:

  1. Navigate to Models from the left toolbar
  2. Select New Model
  3. From the dropdown menu, select From sample JSON

Step 1 - Copy Sample JSON document

  1. Copy sample JSON document
  2. Select Next to move to the next step

Step 2 - Review model definition

The model definition is automatically generated using the sample JSON document. Altogic automatically adds _id and _parent fields to the model and its sub-models.

  1. Review model definition and, if needed, change the field type from the dropdown list or delete the field if it is not required
  2. Select Next to move to the final step
info

While the model definition is automatically generated using the sample JSON document, Altogic ignores fields that do not match its naming convention.

  • A model field can max 40 characters long
  • Only numbers, letters, and underscore '_' allowed in field names
  • A field name cannot start with a number or underscore '_' character

Step 3 - Set model name and timestamps

  1. Provide a unique name (case insensitive) to your new model, select model group, specify whether the model is permanent or transient and enable/disable timestamps
  2. Select Create to create the new model

Step 3 - Select default endpoints (permanent models only)

  1. Select the default CRUD endpoints and associated services that will be automatically created when creating the model
  2. Select Create to create the new model
info

Default endpoints selection is applicable only for permanent models. Altogic does not create CRUD endpoints for transient models which are not stored in the database.