Skip to content

Commit 4d93a5c

Browse files
committed
docs: add another note about schema.virtual()
1 parent 36e0c4e commit 4d93a5c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

docs/typescript/virtuals.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ const schema = new Schema(
2828
);
2929
```
3030

31+
If you are using automatic schema inference, you should define virtuals using the `virtuals` option in the schema constructor as shown above.
32+
Mongoose will not automatically infer any virtuals you define using `Schema.prototype.virtual()`.
33+
3134
Note that Mongoose does **not** include virtuals in the returned type from `InferSchemaType`.
3235
That is because `InferSchemaType` returns a value similar to the raw document interface, which represents the structure of the data stored in MongoDB.
3336

0 commit comments

Comments
 (0)