mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:45:18 +00:00
fix: ignore some typescript error (#59)
This commit is contained in:
parent
82355e1422
commit
9a27eac0e0
@ -228,7 +228,7 @@ export abstract class Model extends SequelizeModel {
|
||||
alias || Utils.underscoredIf(`${association}Count`, this.options.underscored),
|
||||
].filter(Boolean);
|
||||
|
||||
return attribute as ProjectionAlias;
|
||||
return attribute as unknown as ProjectionAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -151,6 +151,7 @@ export class Table {
|
||||
this.defaultModel = getRegisteredModel(model);
|
||||
this.modelAttributes = {};
|
||||
// 在 set fields 之前 model init 的原因是因为关系字段可能需要用到 model 的相关配置
|
||||
// @ts-ignore
|
||||
this.addIndexes(indexes, 'modelOnly');
|
||||
// this.modelInit('modelOnly');
|
||||
this.setFields(fields);
|
||||
@ -330,15 +331,13 @@ export class Table {
|
||||
/**
|
||||
* 添加索引
|
||||
*
|
||||
* @param options
|
||||
* @param indexOptions
|
||||
* @param reinitialize
|
||||
*/
|
||||
public addIndex(options: string | ModelIndexesOptions, reinitialize: Reinitialize = true) {
|
||||
if (typeof options === 'string') {
|
||||
options = {
|
||||
fields: [options],
|
||||
};
|
||||
}
|
||||
public addIndex(indexOptions: string | ModelIndexesOptions, reinitialize: Reinitialize = true) {
|
||||
const options = typeof indexOptions === 'string' ? {
|
||||
fields: [indexOptions],
|
||||
} : indexOptions;
|
||||
// @ts-ignore
|
||||
const index = Utils.nameIndex(options, this.options.name);
|
||||
console.log(this.options, { index, options });
|
||||
@ -386,6 +385,7 @@ export class Table {
|
||||
for (const key in fields) {
|
||||
this.addField(fields[key], false);
|
||||
}
|
||||
// @ts-ignore
|
||||
this.addIndexes(indexes, false);
|
||||
this.modelInit(true);
|
||||
}
|
||||
|
@ -167,9 +167,11 @@ export class CollectionModel extends BaseModel {
|
||||
});
|
||||
}
|
||||
if (collection && update) {
|
||||
// @ts-ignore
|
||||
await collection.update(data, options);
|
||||
}
|
||||
if (!collection) {
|
||||
// @ts-ignore
|
||||
collection = await this.create(data, options);
|
||||
}
|
||||
const associations = ['fields', 'tabs', 'actions', 'views'];
|
||||
@ -211,11 +213,15 @@ export class CollectionModel extends BaseModel {
|
||||
await model.update({...item, sort: index+1}, options);
|
||||
}
|
||||
if (!model) {
|
||||
model = await Model.create({
|
||||
...item,
|
||||
sort: index+1,
|
||||
collection_name: collection.name,
|
||||
}, options);
|
||||
model = await Model.create(
|
||||
{
|
||||
...item,
|
||||
sort: index+1,
|
||||
collection_name: collection.name,
|
||||
},
|
||||
// @ts-ignore
|
||||
options
|
||||
);
|
||||
}
|
||||
if (model) {
|
||||
if (key === 'tabs') {
|
||||
|
@ -1,12 +1,11 @@
|
||||
import _ from 'lodash';
|
||||
import BaseModel from './base';
|
||||
import { FieldOptions } from '@nocobase/database';
|
||||
import { FieldOptions, BELONGSTO, BELONGSTOMANY, HASMANY } from '@nocobase/database';
|
||||
import * as types from '../interfaces/types';
|
||||
import { merge } from '../utils';
|
||||
import { BuildOptions } from 'sequelize';
|
||||
import { SaveOptions, Utils } from 'sequelize';
|
||||
import { generateCollectionName } from './collection';
|
||||
import { BELONGSTO, BELONGSTOMANY, HASMANY } from '@nocobase/database';
|
||||
|
||||
interface FieldImportOptions extends SaveOptions {
|
||||
parentId?: number;
|
||||
@ -243,10 +242,14 @@ export class FieldModel extends BaseModel {
|
||||
} else {
|
||||
tmp.collection_name = collectionName;
|
||||
}
|
||||
model = await this.create({
|
||||
...item,
|
||||
...tmp,
|
||||
}, options);
|
||||
model = await this.create(
|
||||
{
|
||||
...item,
|
||||
...tmp,
|
||||
},
|
||||
//@ts-ignore
|
||||
options
|
||||
);
|
||||
}
|
||||
if (Array.isArray(item.children)) {
|
||||
const childrenIds = await this.import(item.children, {
|
||||
|
@ -23,10 +23,14 @@ export class PageModel extends BaseModel {
|
||||
},
|
||||
});
|
||||
if (!page) {
|
||||
page = await this.create({
|
||||
...item,
|
||||
parent_id: parentId,
|
||||
}, options);
|
||||
page = await this.create(
|
||||
{
|
||||
...item,
|
||||
parent_id: parentId,
|
||||
},
|
||||
// @ts-ignore
|
||||
options
|
||||
);
|
||||
}
|
||||
if (Array.isArray(item.children)) {
|
||||
await this.import(item.children, {
|
||||
|
Loading…
Reference in New Issue
Block a user