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

Bug: Can't use Instance of Number in query #8150

Closed
tomasgvivo opened this issue Sep 10, 2019 · 0 comments
Closed

Bug: Can't use Instance of Number in query #8150

tomasgvivo opened this issue Sep 10, 2019 · 0 comments
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@tomasgvivo
Copy link

What is the current behavior?
When using instance of Number in filter mongo recieves an empty object instead of the number.

If the current behavior is a bug, please provide the steps to reproduce.

const mySchema = new Schema({
  id: {
    type: Number,
    set: value => {
      return new Number(value.valueOf());
    }
  }
});

const MyModel = mongoose.model('MyModel', mySchema);

MyModel.findOne({ id: 12345 });
command: find { find: "mymodel", filter: { id: {} }, projection: {}, limit: 1, singleBatch: true, batchSize: 1, returnKey: false, showRecordId: false, lsid: { id: UUID("blahblahblah") }, $db: "mydb" }

What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
Node: 12
Mongo: 4.2
Mongoose: 5.7.0

@tomasgvivo tomasgvivo changed the title Bug: Bug: Can't use Instance of Number in query Sep 10, 2019
@vkarpov15 vkarpov15 added this to the 5.7.2 milestone Sep 13, 2019
@vkarpov15 vkarpov15 added has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue labels Sep 13, 2019
vkarpov15 added a commit that referenced this issue Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
Development

No branches or pull requests

2 participants