# Ref Decorator mongoose property
Module | import { Ref } from "@tsed/mongoose" |
---|---|
Source | /packages/mongoose/src/decorators/ref.ts |
# Overview
function Ref(model: string | any, type?: MongooseSchemaTypes): any;
export type Ref<T> = T | string;
# Description
Define a property as mongoose reference to other Model (decorated with @Model).
# Example
@Model()
class FooModel {
@Ref(Foo2Model)
field: Ref<Foo2Model>
@Ref(Foo2Model)
list: Ref<Foo2Model>[]
}
@Model()
class Foo2Model {
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing