Skip to main content
Relations work a little differently in mongoose when compared to other relational ORMs such as sequelize or typescript. You can read more about relations (references) in mongoose here
There are multiple ways to set of references in mongoose there are intended as starting point.
Filtering on references is not supported by mongoose.

One to Many/Many To One Example

To set up a one to many/many to one relationship in mongoose you will store a reference in your document For example lets add sub tasks to our todo items by storing a todoItem ref on our subTask
todo-item/todo-item.entity.ts
Now that we have the relationship defined we can add the @Relation and @CursorConnection to our DTOs
todo-item/todo-item.dto.ts

Many To Many Example

In this example we’ll add tags to todoItems by storing an array of tag references on the todoItems.
todo-item/todo-item.entity.ts
Now that we have the relationship defined we can add the @CursorConnection to our DTOS
todo-item/todo-item.dto.ts