chore: remove unused code + delete existing feeds before seeding
This commit is contained in:
parent
3774c0b6db
commit
60cb0083f5
@ -13,22 +13,6 @@ function generateRandomChannelId() {
|
|||||||
return Math.floor(Math.random() * (max - min + 1)) + min + '';
|
return Math.floor(Math.random() * (max - min + 1)) + min + '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function createRandomChannels(): Prisma.Prisma.ChannelCreateNestedManyWithoutFeedInput {
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
return { createMany: { data: [] } };
|
|
||||||
}
|
|
||||||
|
|
||||||
const channels: Prisma.Prisma.ChannelCreateNestedManyWithoutFeedInput = {
|
|
||||||
createMany: {
|
|
||||||
data: Array.from({ length: 5 }, () => ({
|
|
||||||
channel_id: generateRandomChannelId()
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return channels;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createManyChannels(feedId: number) {
|
async function createManyChannels(feedId: number) {
|
||||||
const channelData: Prisma.Prisma.ChannelCreateManyInput[] = [ ];
|
const channelData: Prisma.Prisma.ChannelCreateManyInput[] = [ ];
|
||||||
|
|
||||||
@ -44,6 +28,10 @@ async function createManyChannels(feedId: number) {
|
|||||||
await client.channel.createMany({ data: channelData });
|
await client.channel.createMany({ data: channelData });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function deleteAllFeeds() {
|
||||||
|
await client.feed.deleteMany()
|
||||||
|
}
|
||||||
|
|
||||||
async function createManyFeeds() {
|
async function createManyFeeds() {
|
||||||
const feedData: Prisma.Prisma.FeedCreateManyInput[] = [ ];
|
const feedData: Prisma.Prisma.FeedCreateManyInput[] = [ ];
|
||||||
|
|
||||||
@ -69,6 +57,7 @@ async function createManyFeeds() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
|
await deleteAllFeeds();
|
||||||
await createManyFeeds();
|
await createManyFeeds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user