Skip to content

Support array of objects #4

@choyongjoon

Description

@choyongjoon

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions