mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
4a58559331
@ -56,19 +56,6 @@ export class SortField extends Field {
|
||||
|
||||
initRecordsSortValue = async (options) => {
|
||||
const { transaction } = options;
|
||||
const orderField = (() => {
|
||||
const model = this.collection.model;
|
||||
|
||||
if (model.primaryKeyAttribute) {
|
||||
return model.primaryKeyAttribute;
|
||||
}
|
||||
|
||||
if (model.rawAttributes['createdAt']) {
|
||||
return model.rawAttributes['createdAt'].field;
|
||||
}
|
||||
|
||||
throw new Error(`can not find order key for collection ${this.collection.name}`);
|
||||
})();
|
||||
|
||||
const needInit = async (scopeKey = null, scopeValue = null) => {
|
||||
const filter = {};
|
||||
@ -93,6 +80,23 @@ export class SortField extends Field {
|
||||
};
|
||||
|
||||
const doInit = async (scopeKey = null, scopeValue = null) => {
|
||||
const orderField = (() => {
|
||||
const model = this.collection.model;
|
||||
|
||||
if (model.primaryKeyAttribute) {
|
||||
const primaryKeyAttribute = model.rawAttributes[model.primaryKeyAttribute];
|
||||
if (primaryKeyAttribute.autoIncrement) {
|
||||
return primaryKeyAttribute.field;
|
||||
}
|
||||
}
|
||||
|
||||
if (model.rawAttributes['createdAt']) {
|
||||
return model.rawAttributes['createdAt'].field;
|
||||
}
|
||||
|
||||
throw new Error(`can not find order key for collection ${this.collection.name}`);
|
||||
})();
|
||||
|
||||
const queryInterface = this.collection.db.sequelize.getQueryInterface();
|
||||
|
||||
if (scopeKey) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user