I want to create the data model(Schema) in node js according to the the database shown in the picture. How to create the data model of array in node js and also the inside the array which have object, which also contain another array?
Asked
Active
Viewed 50 times
1
-
Does this answer your question? [How To Create Mongoose Schema with Array of Object IDs?](https://stackoverflow.com/questions/22244421/how-to-create-mongoose-schema-with-array-of-object-ids) – Matheus Hatje Nov 12 '19 at 12:12
-
But i am confused in the picture attached is the indicator. How to define it in schema – Matih Ullah Nov 12 '19 at 12:25
1 Answers
0
const mongoose = require('mongoose');
mongoose.pluralize(null);
const Schema = mongoose.Schema;
const indicatorsSchema = new Schema({
name:String,
metrics:[String] //[String] define array of string
}, { _id: false });
const Learning = new Schema({
learningEvents: String,
learningActivities: [String], //[String] define array of string
indicators:[indicatorsSchema] // define object as above
}, { versionKey: false })

Jeet Shekhaliya
- 53
- 10