Skip to content

Commit

Permalink
Refactor virtuals.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammad0-0ahmad committed Jun 21, 2022
1 parent d2707d0 commit 6317e97
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/typescript/virtuals.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[Virtuals](/docs/tutorials/virtuals.html) are computed properties: you can access virtuals on hydrated Mongoose documents, but virtuals are **not** stored in MongoDB.
Mongoose supports auto typed virtuals so you don't need to define additional typescript interface anymore but you are still able to do so.

### 1- Auto types:
### Automatically Inferred Types:

To make mongoose able to infer virtuals type, You have to define them in schema constructor as following:

Expand All @@ -28,7 +28,7 @@ const schema = new Schema(
);
```

### 2- Manual types:
### Set virtuals type manually:
You shouldn't define virtuals in your TypeScript [document interface](/docs/typescript.html).
Instead, you should define a separate interface for your virtuals, and pass this interface to `Model` and `Schema`.

Expand Down

0 comments on commit 6317e97

Please sign in to comment.