OptionaloptionsArg: Subset<PrismaClientOptions, PrismaClientOptions>const prisma = new PrismaClient()
// Fetch zero or more Users
const users = await prisma.user.findMany()
Read more in our docs.
prisma.author: Exposes CRUD operations for the Author model.
prisma.book: Exposes CRUD operations for the Book model.
prisma.bookGenres: Exposes CRUD operations for the BookGenres model.
prisma.bookIsbn: Exposes CRUD operations for the BookIsbn model.
prisma.bookStatistics: Exposes CRUD operations for the BookStatistics model.
prisma.comment: Exposes CRUD operations for the Comment model.
prisma.commentLike: Exposes CRUD operations for the CommentLike model.
prisma.favoriteAuthor: Exposes CRUD operations for the FavoriteAuthor model.
prisma.favoriteBook: Exposes CRUD operations for the FavoriteBook model.
prisma.favoriteGenre: Exposes CRUD operations for the FavoriteGenre model.
prisma.genres: Exposes CRUD operations for the Genres model.
prisma.haveReadIt: Exposes CRUD operations for the HaveReadIt model.
prisma.rating: Exposes CRUD operations for the Rating model.
prisma.user: Exposes CRUD operations for the User model.
Connect with the database
Disconnect from the database
Executes a prepared raw query and returns the number of affected rows.
const result = await prisma.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};`
Read more in our docs.
Executes a raw query and returns the number of affected rows. Susceptible to SQL injections, see documentation.
const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
Read more in our docs.
Performs a prepared raw query and returns the SELECT data.
const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};`
Read more in our docs.
Performs a raw query and returns the SELECT data.
Susceptible to SQL injections, see documentation.
const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
Read more in our docs.
Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
Optionaloptions: { isolationLevel?: TransactionIsolationLevel }const [george, bob, alice] = await prisma.$transaction([
prisma.user.create({ data: { name: 'George' } }),
prisma.user.create({ data: { name: 'Bob' } }),
prisma.user.create({ data: { name: 'Alice' } }),
])
Read more in our docs.
Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole.
Optionaloptions: {const [george, bob, alice] = await prisma.$transaction([
prisma.user.create({ data: { name: 'George' } }),
prisma.user.create({ data: { name: 'Bob' } }),
prisma.user.create({ data: { name: 'Alice' } }),
])
Read more in our docs.
Prisma Client ʲˢ
Type-safe database client for TypeScript & Node.js