From 3b7143a28276b72ccb06a9101a24bb2502bfc7d0 Mon Sep 17 00:00:00 2001 From: chenos Date: Wed, 18 Jan 2023 16:55:03 +0800 Subject: [PATCH] feat: collection titleField --- packages/core/database/src/collection.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/core/database/src/collection.ts b/packages/core/database/src/collection.ts index 721933fcdb..fb28a933e1 100644 --- a/packages/core/database/src/collection.ts +++ b/packages/core/database/src/collection.ts @@ -3,11 +3,11 @@ import { EventEmitter } from 'events'; import { default as lodash, default as _ } from 'lodash'; import { ModelOptions, + ModelStatic, QueryInterfaceDropTableOptions, SyncOptions, Transactionable, - ModelStatic, - Utils, + Utils } from 'sequelize'; import { Database } from './database'; import { Field, FieldOptions } from './fields'; @@ -62,6 +62,10 @@ export class Collection< return this.options.name; } + get titleField() { + return (this.options.titleField as string) || this.model.primaryKeyAttribute; + } + get db() { return this.context.database; }