Mongoose schema design
Note: this page is outdated. Please visit the latest page Mongoose schema design
1. New project
To create a new project, click the New item on toolbar and select Mongooose project type.
![Mongoose project](https://www.datensen.com/media/pictures/mongoose-new-project.png)
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.
![New mongoose schema](https://www.datensen.com/blog/wp-content/uploads/new-schema-mongoose-300x102.png)
New object appears in the diagram. You can edit schema properties via Right Side panel:
![Mongoose schema properties](https://www.datensen.com/blog/wp-content/uploads/schema-properties-side-panel-mongoose.png)
If you prefer modal dialogs, double click an item on diagram or open popup and choose Edit:
![Edit Mongoose schema - context menu](https://www.datensen.com/blog/wp-content/uploads/editing-schema-mongoose.png)
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 properties of fields](https://www.datensen.com/blog/wp-content/uploads/mongoose-schema-modal-768x373.png)
Property specifics
Property details can be defined in the expanded area.
![Section for Mongoose fields - expanded area](https://www.datensen.com/blog/wp-content/uploads/mongoose-schema-properties-modal-768x531.png)
3. Define hierarchies
In Mongoose projects you can easily define hierarchical structures.
Direct object properties
If you select Object as the data type, you can add and modify properties on the Children tab. The object properties will then be displayed in the diagram.
Child schema
Another option is to create two schemas and then select the second schema as the data type for the main schema.
![Another schema](https://www.datensen.com/blog/wp-content/uploads/mongoose-another-schema-768x675.png)
Referenced schema
Alternatively, you can also create a reference between two schemas.
![Referenced Mongoose Schema](https://www.datensen.com/blog/wp-content/uploads/mongoose-referenced-768x780.png)
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.
![References in Mongoose Schema](https://www.datensen.com/media/pictures/mongoose-reference-sample.png)
5. Script generation for Mongoose
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 script generation](https://www.datensen.com/blog/wp-content/uploads/project-script-768x537.png)
We wish you a pleasant work and simple creation of your Mongoose Schema Design.
For more information about Mongoose, visit https://mongoosejs.com/