Primeiros passos com Prisma + SQLite usando JS
I tried following the tutorial in the documentation, but I'm having trouble using Prisma ORM without TypeScript, as I want to use it with JavaScript and SQLite. Could someone provide me with a step-by-step guide for installation and integration?
3 Replies
You chose to compile with the bot. One moment while I piece together your answer…
Aqui vai um passo‑a‑passo bem direto para usar Prisma ORM + SQLite com JavaScript (sem TypeScript), adaptando o quickstart de TypeScript para JS.
1. Criar o projeto e instalar dependências
O adapter
@prisma/adapter-better-sqlite3 é o usado com SQLite no quickstart de TS.[Quickstart SQLite]
2. Inicializar Prisma com SQLite
Isso cria prisma/schema.prisma, .env e prisma.config.ts.[Quickstart SQLite]
Confirme:
prisma/schema.prisma:
.env:
prisma.config.ts:
3. Definir um modelo
Edite prisma/schema.prisma e adicione um modelo simples:
4. Criar a base e gerar o client
A migração cria dev.db e gera o Prisma Client no diretório configurado.[Migrate] [[Generating client]](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/generating-prisma-cli
ent)
5. Instanciar Prisma Client (JS)
Crie lib/prisma.js:
(Adaptado do exemplo TypeScript, apenas removendo tipos.[Instantiate client])
6. Escrever e rodar o primeiro script JS
Crie script.mjs (para ESM):
Rodar:
As queries seguem o mesmo padrão mostrado na documentação de Prisma Client.[Client intro]Precisa ser .mjs?
🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly.
In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.