fix(mock-collections): mock unique

This commit is contained in:
chenos 2023-12-10 23:44:17 +08:00
parent a7176770fb
commit efb6580eaf
2 changed files with 10 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { faker } from '@faker-js/faker';
import { uid } from '@nocobase/utils';
export const email = {
options: () => ({
@ -11,5 +12,5 @@ export const email = {
'x-validator': 'email',
},
}),
mock: () => faker.internet.email(),
mock: () => faker.internet.email({ lastName: uid() }),
};

View File

@ -222,7 +222,14 @@ export class PluginMockCollectionsServer extends Plugin {
size = values.length;
}
const data = await mockCollectionData(resourceName, size);
// ctx.body = data;
// ctx.body = {
// values: (Array.isArray(data) ? data : [data]).map((item, index) => {
// if (Array.isArray(values)) {
// return { ...item, ...values[index] };
// }
// return { ...item, ...values };
// }),
// };
ctx.body = await repository.create({
values: (Array.isArray(data) ? data : [data]).map((item, index) => {
if (Array.isArray(values)) {