fix(database): create collections with field via http api
This commit is contained in:
parent
acb2e02c11
commit
4657c22ef3
@ -1,5 +1,5 @@
|
|||||||
import { SyncOptions, Transactionable } from 'sequelize';
|
|
||||||
import Database, { MagicAttributeModel } from '@nocobase/database';
|
import Database, { MagicAttributeModel } from '@nocobase/database';
|
||||||
|
import { SyncOptions, Transactionable } from 'sequelize';
|
||||||
|
|
||||||
interface LoadOptions extends Transactionable {
|
interface LoadOptions extends Transactionable {
|
||||||
// TODO
|
// TODO
|
||||||
@ -15,7 +15,7 @@ export class FieldModel extends MagicAttributeModel {
|
|||||||
const { skipExist = false } = loadOptions || {};
|
const { skipExist = false } = loadOptions || {};
|
||||||
const collectionName = this.get('collectionName');
|
const collectionName = this.get('collectionName');
|
||||||
if (!this.db.hasCollection(collectionName)) {
|
if (!this.db.hasCollection(collectionName)) {
|
||||||
throw new Error(`${collectionName} collection does not exist.`);
|
return;
|
||||||
}
|
}
|
||||||
const collection = this.db.getCollection(collectionName);
|
const collection = this.db.getCollection(collectionName);
|
||||||
const name = this.get('name');
|
const name = this.get('name');
|
||||||
@ -29,6 +29,9 @@ export class FieldModel extends MagicAttributeModel {
|
|||||||
const field = await this.load({
|
const field = await this.load({
|
||||||
transaction: options.transaction,
|
transaction: options.transaction,
|
||||||
});
|
});
|
||||||
|
if (!field) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
await field.sync(options);
|
await field.sync(options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user