tachybase_todo/packages/core/database/src/view-collection.ts
ChengLei Shao c7b9e6ac51
feat: infer belongs to association field in view collection (#1756)
support belongs to field in view collection
2023-06-04 13:04:56 +08:00

21 lines
539 B
TypeScript

import { Collection, CollectionContext, CollectionOptions } from './collection';
export class ViewCollection extends Collection {
constructor(options: CollectionOptions, context: CollectionContext) {
options.autoGenId = false;
options.timestamps = false;
super(options, context);
}
protected sequelizeModelOptions(): any {
const modelOptions = super.sequelizeModelOptions();
modelOptions.tableName = this.options.viewName || this.options.name;
return modelOptions;
}
isView() {
return true;
}
}