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

feat(NODE-6503): Add Int32 to SchemaType #15054

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

aditi-khare-mongoDB
Copy link

@aditi-khare-mongoDB aditi-khare-mongoDB commented Nov 22, 2024

This PR follows the one opened on the mongodb fork, Val's initial round of feedback has been addressed.

Summary

Motivation
Support a 32-bit integer type in mongoose for compatibility with CSFLE/QE. The current Number schema type can result in either Int32, Int64, or Doubles that are inserted into the database using type inference but CSFLE and QE require exact BSON types in schemas.

Summary of Changes

  • Add SchemaType Int32, which has the following behavior:
    • its default cast method throws when provided a
      • a non-numeric string
      • a non-integer value
      • a NaN
      • a number beyond the bounds of INT32_MAX or INT32_MIN
    • it is queryable as $type: int or $type: number, but NOT $type: double
  • Add API Docs for new query option and new schema type

Example

const vehicleSchema = new Schema({ numberOfTires: mongoose.Int32 });

@aditi-khare-mongoDB
Copy link
Author

aditi-khare-mongoDB commented Nov 22, 2024

@vkarpov15

I've reopened the PR against the fork, here.

Here's a link to you open comment thread, so we can follow-up on it.

@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review November 22, 2024 19:22
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 this pull request may close these issues.

1 participant