Basic Usage
Let's start with a simple model:
import { GtDocument, GtModel } from '@pebula/goosetyped';
@GtDocument()
export class Customer extends GtModel() {
@GtColumn()
name: string;
@GtColumn()
age: number;
}
Here we have a Customer class with a name and age columns.
- We decorate each column with the
@GtColumndecorator to declare that the property is mapped to a column in the DB. - We decorate each model with the
@GtDocumentdecorator to declare that this is a model. - We extend the
Customerclass with the expressionGtModel()which is extending mongoose'sModelclass with a bit of GooseTyped flavor.
To qualify as a model a class must be decorated with @GtDocument and extend GtModel().
GooseTyped distinguish between documents and sub-documents. This is