简体   繁体   中英

Creating an array INSIDE an array in the mongoose schema

I want to create an array of stores. And in each store, there would be sections. So one store maybe have a deli and produce section. Another store may just cashiers and a meat section.

var UserSchema = new Schema({
  store: {
    type: Array,
  },
  section: { // how do I put this inside the store array?
    type: Array, 
  }
});

we can do it by by specifying type mixed, it will accept any kind of data structre

var UserSchema = new Schema({
  store: [{
        type: Schema.Types.Mixed
    }]
});

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