Skip to content

lost22git/test-elysia

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dev app

install bun

rtx install bun

rtx use -g bun

create test-elysia project

bun create elysia test-elysia

cd test-elysia

install prisma

bun install prisma --save-dev 

init prisma

bun x prisma init --datasource-provider sqlite

edit ./prisma/schema.prisma file

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

model Fighter {
  id         Int       @id @default(autoincrement())
  name       String    @unique
  skill      String
  created_at DateTime  @default(now())
  updated_at DateTime?

  @@map("fighter")
}

edit .env file

# Environment variables declared in this file are automatically made available to Prisma.
# See the documentation for more detail: https://pris.ly/d/prisma-schema#accessing-environment-variables-from-the-schema

# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="file:./fighter.db"

sync schema to db and generate migrate scripts

bun x prisma migrate dev --name init-fighter-schema

generate prisma client code

bun x prisma generate

use PrismaClient in your ts code

import { PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()

run app

start app with one instance

bun src/index.ts

or

bun start

or

./deploy.sh 1

start app with the specified number of instances

# start with 4 instances
./deploy.sh 4

Releases

No releases published

Packages

No packages published