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-6504): Add Double as a SchemaType #3

Closed
wants to merge 8 commits into from

Conversation

aditi-khare-mongoDB
Copy link

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

Summary

Motivation
Support a IEEE 754-2008 floating point 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

  • Same changes as NODE-6503 but for Double.
  • Add SchemaType Double, which has the following behavior:
    • its default cast method throws when provided a
      • a non-numeric string
    • it is queryable as $type: double or $type: number
  • Add API Docs for new query option and new schema type

Example

const vehicleSchema = new Schema({ gasLevel: mongoose.Schema.Types.Double });

@aditi-khare-mongoDB aditi-khare-mongoDB changed the title feat(NODE-6405): Add Double as a SchemaType feat(NODE-6504): Add Double as a SchemaType Nov 13, 2024
@aditi-khare-mongoDB aditi-khare-mongoDB marked this pull request as ready for review November 13, 2024 15:51
lib/cast/double.js Outdated Show resolved Hide resolved
lib/cast/double.js Show resolved Hide resolved
lib/schema/double.js Outdated Show resolved Hide resolved
lib/mongoose.js Outdated Show resolved Hide resolved
test/double.test.js Outdated Show resolved Hide resolved
Copy link

@baileympearson baileympearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small comments

lib/cast/double.js Outdated Show resolved Hide resolved
lib/schema/double.js Show resolved Hide resolved
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.

2 participants