Skip to content

Commit

Permalink
types: add UUID to RefType
Browse files Browse the repository at this point in the history
Fix #15101
  • Loading branch information
vkarpov15 committed Dec 17, 2024
1 parent b9136c1 commit 585abde
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/typescript/populate.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ However, we recommend using the `.populate<{ child: Child }>` syntax from the fi
Here's two reasons why:

1. You still need to add an extra check to check if `child instanceof ObjectId`. Otherwise, the TypeScript compiler will fail with `Property name does not exist on type ObjectId`. So using `PopulatedDoc<>` means you need an extra check everywhere you use `doc.child`.
2. In the `Parent` interface, `child` is a hydrated document, which makes it slow difficult for Mongoose to infer the type of `child` when you use `lean()` or `toObject()`.
2. In the `Parent` interface, `child` is a hydrated document, which makes it difficult for Mongoose to infer the type of `child` when you use `lean()` or `toObject()`.
3 changes: 2 additions & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,8 @@ declare module 'mongoose' {
| typeof Schema.Types.Number
| typeof Schema.Types.String
| typeof Schema.Types.Buffer
| typeof Schema.Types.ObjectId;
| typeof Schema.Types.ObjectId
| typeof Schema.Types.UUID;


export type InferId<T> = T extends { _id?: any } ? T['_id'] : Types.ObjectId;
Expand Down

0 comments on commit 585abde

Please sign in to comment.