Package Exports
- @eggjs/tegg-orm-decorator
- @eggjs/tegg-orm-decorator/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@eggjs/tegg-orm-decorator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@eggjs/tegg-orm-decorator
Install
npm i --save @eggjs/tegg-orm-decoratorDefine Model
import { Model, Attribute } from '@eggjs/tegg-orm-decorator';
import { DataTypes, Bone } from 'leoric';
@Model()
export class App extends Bone {
@Attribute(DataTypes.STRING)
name: string;
@Attribute(DataTypes.STRING)
desc: string;
}Use Model
import { ContextProto, Inject } from '@eggjs/tegg';
import { App } from './model/App';
@ContextProto()
export class AppService {
@Inject()
App: typeof App;
async createApp(data: {
name: string;
desc: string;
}): Promise<App> {
const bone = await this.App.create(data as any);
return bone as App;
}
async findApp(name: string): Promise<App | null> {
const app = await this.App.findOne({ name });
return app as App;
}
}