mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix: use repository.firstOrCreate (#6406)
This commit is contained in:
parent
8741c26a86
commit
ded7b983fb
@ -11,12 +11,12 @@ import { Model, Transaction } from '@nocobase/database';
|
||||
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import { tval } from '@nocobase/utils';
|
||||
import _ from 'lodash';
|
||||
import * as process from 'node:process';
|
||||
import { resolve } from 'path';
|
||||
import { getAntdLocale } from './antd';
|
||||
import { getCronLocale } from './cron';
|
||||
import { getCronstrueLocale } from './cronstrue';
|
||||
import _ from 'lodash';
|
||||
|
||||
async function getLang(ctx) {
|
||||
const SystemSetting = ctx.db.getRepository('systemSettings');
|
||||
@ -221,7 +221,14 @@ export class PluginClientServer extends Plugin {
|
||||
const createModels = tabs
|
||||
.map((x) => !modelsByRouteId[x.get('id')] && { desktopRouteId: x.get('id'), roleName })
|
||||
.filter(Boolean);
|
||||
return await repository.create({ values: createModels, transaction });
|
||||
for (const values of createModels) {
|
||||
await repository.firstOrCreate({
|
||||
values,
|
||||
filterKeys: ['desktopRouteId', 'roleName'],
|
||||
transaction,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'remove') {
|
||||
|
@ -8,8 +8,8 @@
|
||||
*/
|
||||
|
||||
import { Model, Transaction } from '@nocobase/database';
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import PluginLocalizationServer from '@nocobase/plugin-localization';
|
||||
import { Plugin } from '@nocobase/server';
|
||||
import { tval } from '@nocobase/utils';
|
||||
import _ from 'lodash';
|
||||
|
||||
@ -94,7 +94,14 @@ export class PluginMobileServer extends Plugin {
|
||||
const createModels = tabs
|
||||
.map((x) => !modelsByRouteId[x.get('id')] && { mobileRouteId: x.get('id'), roleName })
|
||||
.filter(Boolean);
|
||||
return await repository.create({ values: createModels, transaction });
|
||||
for (const values of createModels) {
|
||||
await repository.firstOrCreate({
|
||||
values,
|
||||
filterKeys: ['mobileRouteId', 'roleName'],
|
||||
transaction,
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'remove') {
|
||||
|
Loading…
x
Reference in New Issue
Block a user