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