1
0
Fork 0
polaris-task-force/src/tools/seed/seedFactions.ts

78 lines
1.8 KiB
TypeScript

import { getPayload } from "payload";
import config from "@payload-config";
import { Faction } from "@/payload-types";
// These are the default factions as of the campaign "The World We Knew".
const DEFAULT_FACTIONS: Omit<Faction, "id" | "sizes" | "createdAt" | "deletedAt" | "updatedAt">[] =
[
{
name: "American Reclamation Project",
description: null,
playableFaction: true,
startingFaction: true,
type: "majorFaction",
},
{
name: "Eurasian Redevelopment Alliance",
description: null,
playableFaction: true,
startingFaction: true,
type: "majorFaction",
},
{
name: "Worldmark",
description: null,
playableFaction: true,
startingFaction: true,
type: "majorFaction",
},
{
name: "Inheritors",
description: null,
playableFaction: true,
startingFaction: true,
type: "minorFaction",
},
{
name: "Deepwell",
description: null,
playableFaction: true,
startingFaction: true,
type: "minorFaction",
},
{
name: "New Horizons",
description: null,
playableFaction: true,
startingFaction: true,
type: "minorFaction",
},
];
export const seedFactions = async () => {
const payload = await getPayload({ config });
payload.logger.info("Seeding faction data...");
payload.logger.warn("Deleting all existing factions...");
await payload.delete({
collection: "factions",
where: {
name: { exists: true },
},
});
payload.logger.info(`Creating ${DEFAULT_FACTIONS.length} new factions...`);
for (const faction of DEFAULT_FACTIONS) {
const result = await payload.create({
collection: "factions",
data: {
...faction,
},
});
payload.logger.info(`Faction '${result.name}' created.`);
}
};
await seedFactions();