mooseql icon indicating copy to clipboard operation
mooseql copied to clipboard

Support array of objects

Open choyongjoon opened this issue 8 years ago • 0 comments

The array of objects (like books in below) cause the error TypeError: Cannot read property 'ref' of undefined

const userSchema = new Schema({
  name: {
    first: { type: String, required: 'first name required' },
    last: String
  },
  school: { type: Schema.Types.ObjectId, ref: 'School' },
  books: [{
    title: String
    subject: String
  }]
})
uncaughtException TypeError: Cannot read property 'ref' of undefined
  at inheritOpts.forEach.opt (mooseql/src/type/index.js:86:64)
  at Array.forEach (native)
  at _fields.filter.map.path (mooseql/src/type/index.js:85:19)
  at Array.map (native)
  at toType (mooseql/src/type/index.js:81:6)
  at models.filter.reduce (mooseql/src/type/index.js:31:52)
  at Array.reduce (native)
  at modelsToTypes (mooseql/src/type/index.js:30:6)
  at mooseql (mooseql/src/index.js:6:19)

choyongjoon avatar Feb 17 '17 08:02 choyongjoon