Mongoose schema design

Quick start guide for Mongoose schema design in Moon Modeler.

  1. New project
  2. Mongoose schema design - schemata
  3. Mongoose schema design - nested types
  4. Embedded documents, schema and references
  5. Code generation

1. New project

To create a new project, click the New item on toolbar and select Mongooose project type.

Mongoose project
Later you can edit the project and choose colors for background, lines and footer.

2. Design schemata

To add a new schema to your Mongoose schema design, click the Schema item on toolbar and then click the diagram area.

Toolbar

New object appears in the diagram. You can edit schema properties via Right Side panel:

Mongoose properties - right side panel

If you prefer modal dialogs, double click an item on diagram or open popup and choose Edit:
Popup

Properties

You can add new properties to a Mongoose schema in section Properties.
Specify new property name, datatype and click Add.

Param is a logical information only and doesn't affect generated code.
NN stands for Not Null and indicates a required property.
ARR stands for Array.

Mongoose schema definition

Property specifics

Property details can be defined in the expanded area.

Modal

3. Design nested types

Nested types in Mongoose schema design are objects that can be embedded to schemata or other nested objects.

Example: The following screenshot shows different ways how to define structure in Mongoose.

Mongoose schema design

Compare the generated scripts.

Nested types

Mongoose - nested type

Child schema

Mongoose - child schema

Referenced schema

Mongoose - referenced schema

To create new Nested type, click the Nested type icon on toolbar and then click the main area.

Embedding nested types to a schema

To embed a nested type to a schema, edit the target schema and select nested type name from Datatype selectbox.

Embedded nested type

Schema vs Nested types

During your design process you might consider changing existing nested type to a schema or vice versa. In order to avoid manual redefinition, enable or disable the Nested type switch.

Switch

4. References in Mongoose schema design

References represent links between schemata. To create a new reference, click the Reference icon on toolbar and then click source schema and then target schema in your diagram. New property is added to target schema automatically.

Referenced schema

 

5. Code generation

To preview script generated for Mongoose click the Script tab on schema detail.

To save scripts to files, click the Script icon on toolbar and then click Save scripts button.

Mongoose schema design - generated scripts

The end of Mongoose schema design quick start guide.

Copyright: 2019 Datensen. All rights reserved.
This website is not endorsed by MongoDB, Inc.
This website uses cookies to ensure you get the best experience on our website.