Lick A Brick
Lick A Brick
Explore posts from servers
DTDrizzle Team
Created by Lick A Brick on 3/26/2025 in #help
'process is not defined' in Sveltekit SPA
Hi, I have a monorepo (turborepo) and I have my drizzle instance as a package. In my schema I have createInsertSchema I want to use in my frontend to do form validation. The problem is I get the error process is not defined because the code is ran from the client. In FF devtools I see it goes wrong at user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER, (line 8 @ http://localhost:5173/node_modules/pg/lib/defaults.js). Why does it need pg in the first place? I only import the createInsertSchema. Here is the code: /// Database package: packages\database\index.ts
import initDb from "./database";

export * from "./schema";
export default initDb
export * from 'drizzle-orm'
import initDb from "./database";

export * from "./schema";
export default initDb
export * from 'drizzle-orm'
packages\database\database.ts
import { drizzle } from "drizzle-orm/node-postgres";

import * as schema from "./schema";

export default function initDb(databaseUrl: string) {
if (!databaseUrl) {
throw new Error("A valid DATABASE_URL must be provided.");
}
return drizzle(databaseUrl, { schema });
}
import { drizzle } from "drizzle-orm/node-postgres";

import * as schema from "./schema";

export default function initDb(databaseUrl: string) {
if (!databaseUrl) {
throw new Error("A valid DATABASE_URL must be provided.");
}
return drizzle(databaseUrl, { schema });
}
packages\database\schema.ts
import { relations } from "drizzle-orm";
import { pgTable, text, integer, timestamp, boolean } from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
import { nanoid } from "nanoid";
import { z } from "zod";

export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
emailVerified: boolean('email_verified').notNull(),
image: text('image'),
createdAt: timestamp('created_at').notNull(),
updatedAt: timestamp('updated_at').notNull()
});

.... nothing special should follow....
import { relations } from "drizzle-orm";
import { pgTable, text, integer, timestamp, boolean } from "drizzle-orm/pg-core";
import { createInsertSchema, createSelectSchema, createUpdateSchema } from "drizzle-zod";
import { nanoid } from "nanoid";
import { z } from "zod";

export const user = pgTable("user", {
id: text("id").primaryKey(),
name: text('name').notNull(),
email: text('email').notNull().unique(),
emailVerified: boolean('email_verified').notNull(),
image: text('image'),
createdAt: timestamp('created_at').notNull(),
updatedAt: timestamp('updated_at').notNull()
});

.... nothing special should follow....
//// My Sveltekit app The code lives in a component e.g. myForm.svelte
<script lang="ts">
import { userCreateSchema } from '@myrepo/database';
</script>
<script lang="ts">
import { userCreateSchema } from '@myrepo/database';
</script>
Simply importing the create schema makes it pop the error. Any help is appreciated.
2 replies
DTDrizzle Team
Created by Lick A Brick on 3/25/2025 in #help
Can't get Drizzle working in turborepo as package
I can't get Drizzle working as package in turborepo, getting all kind of TS errors. Does anyone have a working example? I am using Sveltekit as the frontend, hono as the backend (with nodeJS) and want to use a message queue worker (BullMQ in my case) too as a seperate app. Both Hono and the message queue will need to access drizzle, thats why I want to use Drizzle as a package.
1 replies
BABetter Auth
Created by Lick A Brick on 3/13/2025 in #help
Organizations plugin with Drizzle RLS
Hi, I am creating a hobby project which is a multi tenant app (using the organisations plugin). I use Hono to serve a CRUD API. How can I: - Restrict certain columns to users with certain roles (keeping in mind a user can belong to multiple organisations with different roles between organisations) - Make sure users can only retrieve records which belong to their organisation(s) - Restrict creating / updating records in certain tables to certain roles? Am I correct it would be better to add these restrictions on the DB level or is it better to manage this at the API (Hono in my case) level?
1 replies
PD🧩 Plasmo Developers
Created by Lick A Brick on 8/7/2024 in #🔰newbie
Overwrite existing CSS/Styling on page
Hi, how can I overwrite existing CSS on a webpage?
3 replies