feat: collection titleField

This commit is contained in:
chenos 2023-01-18 16:55:03 +08:00
parent aaf6718755
commit 3b7143a282

View File

@ -3,11 +3,11 @@ import { EventEmitter } from 'events';
import { default as lodash, default as _ } from 'lodash'; import { default as lodash, default as _ } from 'lodash';
import { import {
ModelOptions, ModelOptions,
ModelStatic,
QueryInterfaceDropTableOptions, QueryInterfaceDropTableOptions,
SyncOptions, SyncOptions,
Transactionable, Transactionable,
ModelStatic, Utils
Utils,
} from 'sequelize'; } from 'sequelize';
import { Database } from './database'; import { Database } from './database';
import { Field, FieldOptions } from './fields'; import { Field, FieldOptions } from './fields';
@ -62,6 +62,10 @@ export class Collection<
return this.options.name; return this.options.name;
} }
get titleField() {
return (this.options.titleField as string) || this.model.primaryKeyAttribute;
}
get db() { get db() {
return this.context.database; return this.context.database;
} }