Skip to content

Commit 40b94b2

Browse files
chore: minor improvements
1 parent 8fa9a3d commit 40b94b2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

content/techniques/mongo.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ In case there are multiple owners, your property configuration should look as fo
8989
owners: Owner[];
9090
```
9191

92-
If you do not plan on always populating a reference to another collection, you should consider using `mongoose.Types.ObjectId` as the type instead:
92+
If you don’t intend to always populate a reference to another collection, consider using `mongoose.Types.ObjectId` as the type instead:
9393

9494
```typescript
9595
@Prop({ type: { type: mongoose.Schema.Types.ObjectId, ref: 'Owner' } })
96-
// This is crucial to not confuse the field with a populated reference
96+
// This ensures the field is not confused with a populated reference
9797
owner: mongoose.Types.ObjectId;
9898
```
9999

100-
Then when you want to selectively populate it later, you can make use of a repository function that specifies the correct type:
100+
Then, when you need to selectively populate it later, you can use a repository function that specifies the correct type:
101101

102102
```typescript
103103
import { Owner } from './schemas/owner.schema';
@@ -108,7 +108,7 @@ async findAllPopulated() {
108108
}
109109
```
110110

111-
> info **Hint** If there is no foreign document to populate, the type might be `Owner | null` depending on your (mongoose configuration)[https://mongoosejs.com/docs/populate.html#doc-not-found], or it might throw, in which case the type will be `Owner`.
111+
> info **Hint** If there is no foreign document to populate, the type could be `Owner | null`, depending on your [Mongoose configuration](https://mongoosejs.com/docs/populate.html#doc-not-found). Alternatively, it might throw an error, in which case the type will be `Owner`.
112112
113113
Finally, the **raw** schema definition can also be passed to the decorator. This is useful when, for example, a property represents a nested object which is not defined as a class. For this, use the `raw()` function from the `@nestjs/mongoose` package, as follows:
114114

0 commit comments

Comments
 (0)