prisma-starter/src/main.ts
Sambo Chea 0f3746f189
Some checks reported errors
continuous-integration/drone/push Build encountered an error
Add tests and functions
Allow to run jests and add the excepted
Add not resolve yet for the async in tests
2021-03-13 11:27:14 +07:00

41 lines
782 B
TypeScript

import { PrismaClient } from "@prisma/client";
import { createUser, createProfile } from "./User/UserService";
const prisma = new PrismaClient();
// main function
async function main() {
const email = "ops@cubetiqs.com";
const name = "CUBETIQ Solution";
// create user
await createUser(
{
name: name,
email: email,
}
)
.then((user) => {
if (user != null) {
// create profile for user
createProfile(user, {
bio: "Software Developer",
});
}
})
.catch((e) => {
console.error(e);
});
const allUsers = await prisma.user.findMany();
console.log("All users => ", allUsers);
}
main()
.catch((e) => {
throw e;
})
.finally(async () => {
await prisma.$disconnect();
});