This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users { | |
constructor(private env: Env) {} | |
async getUser(userId: string) { | |
// ... | |
} | |
// ... | |
} | |
type PickMatching<T, V> = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { drizzle } from "drizzle-orm/d1"; | |
import { AutoRouter, type IRequest, error } from "itty-router"; | |
import { eq } from "drizzle-orm"; | |
import { relations } from "drizzle-orm"; | |
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core"; | |
export const posts = sqliteTable("posts", { | |
id: integer("id").primaryKey({ autoIncrement: true }), | |
title: text("title"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// migrator.ts | |
// keep in base dir of your project (i.e. next to prisma, src, etc) | |
import { readdirSync, appendFileSync } from "node:fs"; | |
import { $ } from "bun"; | |
const dbBinding = "fdgl-maindb"; // change this, make it reflect the binding you have in your wrangler.toml | |
const sqlSchema = | |
await $`bun prisma migrate diff --from-local-d1 --to-schema-datamodel ./prisma/schema.prisma --script`.text(); |