-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
What is the proper way to replace _id
type from ObjectId
to UUID
in mongoose 6
#13032
Labels
docs
This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone
Comments
lpizzinidev
added a commit
to lpizzinidev/mongoose
that referenced
this issue
Feb 15, 2023
vkarpov15
added a commit
to lpizzinidev/mongoose
that referenced
this issue
Feb 15, 2023
vkarpov15
added a commit
that referenced
this issue
Feb 15, 2023
schematype(UUID): added null check to prevent error on binaryToString conversion
vkarpov15
added a commit
that referenced
this issue
Mar 17, 2023
vkarpov15
added a commit
that referenced
this issue
Mar 21, 2023
vkarpov15
added a commit
that referenced
this issue
Mar 21, 2023
docs(guide+schematypes): add UUID to schematypes guide
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussed in #13025
Originally posted by Freezystem February 11, 2023
I've read a lot of post in SO or GH where people are trying to implement UUIDs properly instead of ObjectIds. But these posts are a bit outdated for most of them or incomplete. I also wanted to avoid third party librairies like mongoose-uuid2.
The official documentation is not even mentioning the official
UUID
schema type.I also have read that storing UUIDs as
Buffer
instead ofString
improve overall storage and index performance but it could be false.Also it is not clear if I should use
uuidv1
oruuidv4
generator as mongooseUUID
type mention both in its source.So for the moment I'm doing something like this:
But I get some errors, especially with the organization reference when I try to destructure a newly created user and organization isn't provided, example:
Seems like the UUID getter is missing an
undefined
ornull
test before trying to cast it or maybe I'm missing something.If I remove
organization
the error does not occur.The text was updated successfully, but these errors were encountered: