Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayType is not handling options correctly #716

Closed
gsi-alejandro opened this issue Apr 4, 2023 · 0 comments · Fixed by #717
Closed

ArrayType is not handling options correctly #716

gsi-alejandro opened this issue Apr 4, 2023 · 0 comments · Fixed by #717

Comments

@gsi-alejandro
Copy link
Collaborator

ArrayType options are set to undefined even when you use some options.

Current behavior:
Define schema like this:

const userSchema = new Schema({
    test: {default: ()=>[], type: [{type: String, ref: 'Article'}]}
});

Produce:

ArrayType {
  name: 'Article',
  typeName: 'Array',
  options: undefined,
  itemType: ReferenceType {
    name: '',
    typeName: 'Reference',
    options: undefined,
    schema: Schema {
      statics: {},
      methods: {},
      preHooks: {},
      postHooks: {},
      index: {},
      queries: {},
      options: [Object],
      fields: {}
    },
    refModel: 'Article'
  }
}

Notice: options were set to undefined

Correct behavior should be:

ArrayType {
  name: 'Article',
  typeName: 'Array',
  options: {default: ()=>[]},
  itemType: ReferenceType {
    name: '',
    typeName: 'Reference',
    options: undefined,
    schema: Schema {
      statics: {},
      methods: {},
      preHooks: {},
      postHooks: {},
      index: {},
      queries: {},
      options: [Object],
      fields: {}
    },
    refModel: 'Article'
  }
}

Notice: options has the default value set (options: {default: ()=>[]},)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant