简体   繁体   中英

Mongoose Schema in node js

Mongo Database

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?

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 })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM