v1.0.0 #28
|
@ -1,20 +1,37 @@
|
||||||
import authModel from "../src/models/AuthModel";
|
import authModel from "../src/models/AuthModel";
|
||||||
import imageModel, { Image } from "../src/models/ImageModel";
|
import imageModel from "../src/models/ImageModel";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
import { EnforceUniqueError, UniqueEnforcer } from 'enforce-unique';
|
import { UniqueEnforcer } from "enforce-unique";
|
||||||
|
|
||||||
const uniqueEnforcer = new UniqueEnforcer();
|
const uniqueEnforcer = new UniqueEnforcer();
|
||||||
|
|
||||||
export default async function () {
|
export default async function () {
|
||||||
const images = faker.helpers.multiple(() => ({
|
const images = faker.helpers.multiple(
|
||||||
|
() => ({
|
||||||
url: uniqueEnforcer.enforce(faker.internet.url),
|
url: uniqueEnforcer.enforce(faker.internet.url),
|
||||||
status: faker.helpers.arrayElement(["available", "unavailable", "consumed"]),
|
status: faker.helpers.arrayElement([
|
||||||
tags: faker.helpers.arrayElements([
|
"available",
|
||||||
"2girls", "sleeping", "touhou",
|
"unavailable",
|
||||||
"pokemon", "closed_eyes", "yume_nikki",
|
"consumed",
|
||||||
"waifu", "computer", "party", "yuru_camp"
|
]),
|
||||||
], { min: 0, max: 5 }),
|
tags: faker.helpers.arrayElements(
|
||||||
}), {count: {min: 5, max:50}});
|
[
|
||||||
|
"2girls",
|
||||||
|
"sleeping",
|
||||||
|
"touhou",
|
||||||
|
"pokemon",
|
||||||
|
"closed_eyes",
|
||||||
|
"yume_nikki",
|
||||||
|
"waifu",
|
||||||
|
"computer",
|
||||||
|
"party",
|
||||||
|
"yuru_camp",
|
||||||
|
],
|
||||||
|
{ min: 0, max: 5 }
|
||||||
|
),
|
||||||
|
}),
|
||||||
|
{ count: { min: 5, max: 50 } }
|
||||||
|
);
|
||||||
|
|
||||||
// Wait until all images are inserted
|
// Wait until all images are inserted
|
||||||
await Promise.allSettled(images.map((image) => imageModel.create(image)));
|
await Promise.allSettled(images.map((image) => imageModel.create(image)));
|
||||||
|
|
Loading…
Reference in New Issue