Skip to content

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

@tomasgvivo

Description

@tomasgvivo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugWe've confirmed this is a bug in Mongoose and will fix it.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions