Socket
Socket
Sign inDemoInstall

prisma

Package Overview
Dependencies
Maintainers
0
Versions
7395
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma

Prisma is an open-source database toolkit. It includes a JavaScript/TypeScript ORM for Node.js, migrations and a modern GUI to view and edit the data in your database. You can use Prisma in new projects or add it to an existing one.


Version published
Weekly downloads
1.4M
decreased by-31.85%
Maintainers
0
Weekly downloads
 
Created

What is prisma?

Prisma is an open-source database toolkit that includes an ORM (Object-Relational Mapper), migrations, and a query builder for Node.js and TypeScript. It simplifies database access, ensures type safety, and can be used to build GraphQL and REST APIs.

What are prisma's main functionalities?

ORM (Object-Relational Mapping)

Prisma's ORM allows you to interact with your database through an object-oriented model. The code sample demonstrates how to fetch all users from the database using Prisma's ORM.

const { PrismaClient } = require('@prisma/client');
const prisma = new PrismaClient();

async function main() {
  const allUsers = await prisma.user.findMany();
  console.log(allUsers);
}

main()
  .catch(e => {
    throw e
  })
  .finally(async () => {
    await prisma.$disconnect()
  });

Migrations

Prisma Migrate generates and runs SQL migrations based on your Prisma schema. The code sample shows how to create and apply a new migration called 'init'.

npx prisma migrate dev --name init

Type Safety

Prisma ensures type safety by generating TypeScript types based on your database schema. The code sample demonstrates fetching a user with a specific ID and the result is typed as 'User'.

const user: User = await prisma.user.findUnique({ where: { id: 1 } });

Data Modeling

Prisma uses a schema file to model your database. The code sample shows a Prisma schema definition for a User model with an auto-incrementing ID, name, and unique email.

model User {
  id    Int     @id @default(autoincrement())
  name  String
  email String  @unique
}

Query Builder

Prisma's query builder allows you to construct complex queries with ease. The code sample demonstrates ordering users by their name in ascending order.

const sortedUsers = await prisma.user.findMany({
  orderBy: {
    name: 'asc',
  },
});

Other packages similar to prisma

Keywords

FAQs

Package last updated on 27 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc