dw-postgre
v0.0.8
Published
Projeto destinado a config de conexao ao banco de dados
Downloads
2
Readme
dw-postgre
Começando
npm install dw-postgre
Crie um arquivo .env e adicione as seguintes variaveis
DATABASE_URL
SHADOW_DATABASE_URL
Ambas as váriaveis devem conter a uri de conexão com o banco de dados
A váriavel database_url deve ser preenchida com a uri de conexão com o banco de dados principal
A váriavel shadow_database_url deve ser preenchida com a uri de conexão com o banco de dados sombra, que é uma réplica do banco principal
Configurando
No diretório /src do projeto é necessário criar uma pasta "database" com o arquivo prismaClient.ts(database/prismaClient.ts) com o seguinte conteúdo:
import { prisma } from "dw-postgre";
export { prisma }
No package.json nos scripts é nessário adicionar o script "prestart", ele irá rodar antes do script "start" em produção. Esse script é adicionado para que o prisma crie o schema do banco de dados no node_modules/.prisma/client para ser utilizado dentro do projeto
"prestart": "prisma-generate",
E pronto, agora é só usar o prisma