Julio Barros
Julio Barros
Explore posts from servers
DTDrizzle Team
Created by Julio Barros on 11/3/2023 in #help
migrate with node-postgres
I had migration working well with postgresjs but need to switch to node-postgres for other reasons. But I can't get migration to work and it just hangs. The code I have is:
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import * as schema from "~/db/schema";

const migrationClient = new Client({ connectionString: dbURL });
await migrate(drizzle(migrationClient), {
migrationsFolder: "./migrations",
});
import { drizzle } from "drizzle-orm/node-postgres";
import { migrate } from "drizzle-orm/node-postgres/migrator";
import * as schema from "~/db/schema";

const migrationClient = new Client({ connectionString: dbURL });
await migrate(drizzle(migrationClient), {
migrationsFolder: "./migrations",
});
Also how/where do you set max with pg? TIA.
10 replies
DTDrizzle Team
Created by Julio Barros on 4/5/2023 in #help
jsonb field definition.
What's the right way to define a jsonb field? I have a type type MetaData = {keywords?: string[];} and a field meta: jsonb<MetaData>("meta"), but I'm getting the typescript warnings Type 'PgJsonbBuilderInitial<MetaData>' is not assignable to type 'AnyPgColumnBuilder'.ts(2322) on the lhs and Type 'MetaData' does not satisfy the constraint 'string'.ts(2344) on the rhs. Thanks in advance.
9 replies
DTDrizzle Team
Created by Julio Barros on 3/22/2023 in #help
Getting results in document form rather than record
Hi, new to drizzle but liking it so far. Is there away to get the results in more of a 'document' structure? For example, I'd like to get {id: 1, user: "joe", posts: [{id : 1, title: "my first post"},{id : 2, title: "my second post"}]} rather than in record form [{id: 1, user: "joe", post: {id : 1, title: "my first post"}}, ...}]. I'm doing something like select({id ... post: {id: posts.id, title, posts.title}}). Thanks.
3 replies