Skip to content

Commit

Permalink
feat: 🎸 add createTodos func
Browse files Browse the repository at this point in the history
  • Loading branch information
yeukfei02 committed Apr 21, 2022
1 parent 0ee48e3 commit 33f94da
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions prisma/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const prisma = new PrismaClient();
await createPosts();
await createTags();
await createComments();
await createTodos();
})();

async function createUsers() {
Expand Down Expand Up @@ -143,3 +144,25 @@ async function createComments() {
});
}
}

async function createTodos() {
const todosDataList = [];

const users = await prisma.users.findMany({
take: 100,
});

for (let index = 0; index < 100; index++) {
const todoData = {
todo: faker.lorem.words(),
users_id: users[index].id,
};
todosDataList.push(todoData);
}

if (todosDataList) {
await prisma.todo.createMany({
data: todosDataList,
});
}
}

0 comments on commit 33f94da

Please sign in to comment.