You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lib/src/orm/template/model.ts

31 lines
825 B

import {Template} from "../../cli"
import {UniversalPath} from "../../util"
/**
* Template for creating new database model classes in app/models.
*/
const model_template: Template = {
name: 'model',
fileSuffix: '.model.ts',
baseAppPath: ['models'],
description: 'Create a new class that represents a record in a database',
render: (name: string, fullCanonicalName: string, targetFilePath: UniversalPath) => {
return `import {Model} from "@extollo/orm"
import {Injectable} from "@extollo/di"
/**
* ${name} Model
* -----------------------------------
* Put some description here.
*/
@Injectable()
export class ${name} extends Model<${name}> {
protected static table = '${name.toLowerCase()}';
protected static key = '${name.toLowerCase()}_id';
}
`
}
}
export { model_template }