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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID type in Mongoose 7 #13103

Closed
2 tasks done
jrjake opened this issue Mar 1, 2023 · 0 comments 路 Fixed by #13122
Closed
2 tasks done

UUID type in Mongoose 7 #13103

jrjake opened this issue Mar 1, 2023 · 0 comments 路 Fixed by #13122
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Milestone

Comments

@jrjake
Copy link

jrjake commented Mar 1, 2023

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the feature has not already been requested

馃殌 Feature Proposal

With the release of MongoDB 5+, MongoDB's driver now exposes the UUID type via require('mongodb').BSON.UUID (see API docs.

This means that Mongoose can expose a UUID type for aggregation like it currently does for ObjectId. This would allow developers to aggregate match on UUIDs.

Current workarounds:

import {UUID} from "bson"; // Mongoose 6 and below (works with Mongoose 7 but ill-advised, see https://github.com/mongodb/node-mongodb-native/releases/tag/v5.0.0 "BSON v5" section)
import {BSON} from "mongodb"; // Mongoose 7 and above, use BSON.UUID() below

let my = await My.aggregate().match({_id: new UUID("1e984535-98ad-446b-84cc-bd8f59290eb8")}).exec();

Proposed feature:

import mongoose from "mongoose";

let my = await My.aggregate().match({_id: new mongoose.Types.UUID("1e984535-98ad-446b-84cc-bd8f59290eb8")}).exec();

Motivation

No response

Example

No response

@jrjake jrjake added enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class labels Mar 1, 2023
@vkarpov15 vkarpov15 added this to the 7.1.0 milestone Mar 1, 2023
vkarpov15 added a commit that referenced this issue Apr 25, 2023
feat: handle MongoDB's new UUID type, export `mongoose.Types.UUID`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This issue is a user-facing general improvement that doesn't fix a bug or add a new feature new feature This change adds new functionality, like a new method or class
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants