mbe
mbe
Explore posts from servers
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
yeah but my drizzle studio seems to work fine
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
i had to do a leftJoin but that kinda defeat the purpose
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
okay so i found a solution: const post = await database .select() .from(posts) .where(eq(posts.id, params.postId)) .leftJoin(tags, eq(tags.postId, params.postId)) .leftJoin(links, eq(links.postId, params.postId));
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
im actually unsure how to do this the doc's are very bad at explaining in step to step how to set up one to many
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
is it because i have to add an refernece to my post schema perhaps?
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
at QueryPromise._prepare (./node_modules/drizzle-orm/pg-core/query-builders/query.js:68:60) at eval (./node_modules/drizzle-orm/pg-core/query-builders/query.js:115:19) at Object.startActiveSpan (./node_modules/drizzle-orm/tracing.js:14:14) at QueryPromise.execute (./node_modules/drizzle-orm/pg-core/query-builders/query.js:114:60) at QueryPromise.then (./node_modules/drizzle-orm/query-promise.js:26:17) digest: "88883804" ⨯ Internal error: TypeError: Cannot read properties of undefined (reading 'referencedTable') at normalizeRelation (./node_modules/drizzle-orm/relations.js:211:118) at PgDialect.buildRelationalQueryWithoutPK (./node_modules/drizzle-orm/pg-core/dialect.js:977:101) at QueryPromise._getQuery (./node_modules/drizzle-orm/pg-core/query-builders/query.js:91:25) at QueryPromise._toSQL (./node_modules/drizzle-orm/pg-core/query-builders/query.js:106:24) at eval (./node_modules/drizzle-orm/pg-core/query-builders/query.js:69:42) at Object.startActiveSpan (./node_modules/drizzle-orm/tracing.js:14:14) at QueryPromise._prepare (./node_modules/drizzle-orm/pg-core/query-builders/query.js:68:60) at eval (./node_modules/drizzle-orm/pg-core/query-builders/query.js:115:19) at Object.startActiveSpan (./node_modules/drizzle-orm/tracing.js:14:14) at QueryPromise.execute (./node_modules/drizzle-orm/pg-core/query-builders/query.js:114:60) at QueryPromise.then (./node_modules/drizzle-orm/query-promise.js:26:17) digest: "88883804" GET /dashboard/editor/23423 500 in 16531ms
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
here is the full error message: ⨯ Internal error: TypeError: Cannot read properties of undefined (reading 'referencedTable') at normalizeRelation (./node_modules/drizzle-orm/relations.js:211:118) at PgDialect.buildRelationalQueryWithoutPK (./node_modules/drizzle-orm/pg-core/dialect.js:977:101) at QueryPromise._getQuery (./node_modules/drizzle-orm/pg-core/query-builders/query.js:91:25) at QueryPromise._toSQL (./node_modules/drizzle-orm/pg-core/query-builders/query.js:106:24) at eval (./node_modules/drizzle-orm/pg-core/query-builders/query.js:69:42) at Object.startActiveSpan (./node_modules/drizzle-orm/tracing.js:14:14)
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
let me take a look!
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
any help would be very helpful thank you!
13 replies
DTDrizzle Team
Created by mbe on 9/12/2024 in #help
how to do one to many?
export const tags = pgTable("tags", {
id: text("id").primaryKey(),
postId: integer("post_id"),
tag: text("tag").notNull(),
});
export type TagType = typeof tags.$inferInsert;
export const links = pgTable("links", {
id: text("id").primaryKey(),
postId: integer("post_id"),
url: text("url").notNull(),
});
export type linkType = typeof links.$inferInsert;
export const posts = pgTable(
"posts",
{
id: text("id").primaryKey(),
userId: text("user_id").notNull(),
title: text("title").notNull(),
featured: boolean("featured"),
image: text("image"),
excerpt: text("excerpt").notNull(),
content: text("content").notNull(),
status: text("status", { enum: ["draft", "published"] })
.default("draft")
.notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at", { mode: "date" }).$onUpdate(
() => new Date()
),
},
(t) => ({
userIdx: index("post_user_idx").on(t.userId),
createdAtIdx: index("post_created_at_idx").on(t.createdAt),
})
);

export const linksRelations = relations(links, ({ one }) => ({
post: one(posts, {
fields: [links.postId],
references: [posts.id],
}),
}));
export const tagsRelations = relations(tags, ({ one }) => ({
post: one(posts, {
fields: [tags.postId],
references: [posts.id],
}),
}));
export const postRelations = relations(posts, ({ one, many }) => ({
user: one(users, {
fields: [posts.userId],
references: [users.id],
}),
tags: many(tags),
links: many(links),
}));
export type PostType = typeof posts.$inferInsert;
export const tags = pgTable("tags", {
id: text("id").primaryKey(),
postId: integer("post_id"),
tag: text("tag").notNull(),
});
export type TagType = typeof tags.$inferInsert;
export const links = pgTable("links", {
id: text("id").primaryKey(),
postId: integer("post_id"),
url: text("url").notNull(),
});
export type linkType = typeof links.$inferInsert;
export const posts = pgTable(
"posts",
{
id: text("id").primaryKey(),
userId: text("user_id").notNull(),
title: text("title").notNull(),
featured: boolean("featured"),
image: text("image"),
excerpt: text("excerpt").notNull(),
content: text("content").notNull(),
status: text("status", { enum: ["draft", "published"] })
.default("draft")
.notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at", { mode: "date" }).$onUpdate(
() => new Date()
),
},
(t) => ({
userIdx: index("post_user_idx").on(t.userId),
createdAtIdx: index("post_created_at_idx").on(t.createdAt),
})
);

export const linksRelations = relations(links, ({ one }) => ({
post: one(posts, {
fields: [links.postId],
references: [posts.id],
}),
}));
export const tagsRelations = relations(tags, ({ one }) => ({
post: one(posts, {
fields: [tags.postId],
references: [posts.id],
}),
}));
export const postRelations = relations(posts, ({ one, many }) => ({
user: one(users, {
fields: [posts.userId],
references: [users.id],
}),
tags: many(tags),
links: many(links),
}));
export type PostType = typeof posts.$inferInsert;
13 replies
DTDrizzle Team
Created by mbe on 7/21/2024 in #help
how to use booleans in dizzle?
oh yea i imported it two places thank you
3 replies
DTDrizzle Team
Created by Нарбек on 6/27/2024 in #help
How to combine 'union' and 'orderBy'
Have a great time!
8 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
thank you for trying to help me however it seems to work after 15 min's however im unsure why this happens tbh
12 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
i think its weird because im able to make migrations
12 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
how is my config incorrect?
12 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
im unable to open drizzle studio at all
12 replies
DTDrizzle Team
Created by Sh (@cannnibaldev) on 6/2/2024 in #help
Push doesn't work
are you following a tutorial
12 replies
DTDrizzle Team
Created by mbe on 6/1/2024 in #help
Error: Cannot read properties of undefined (reading 'findMany')
anyway my question is why is items undefined in the findmany? i can easily fetch other things like bids,accounts etc.
3 replies
DTDrizzle Team
Created by mbe on 6/1/2024 in #help
Error: Cannot read properties of undefined (reading 'findMany')
here is my schema where i create my items: export const items = pgTable("bb_item", { id: serial("id").primaryKey(), userId: text("userId") .notNull() .references(() => users.id, { onDelete: "cascade" }), name: text("name").notNull(), });
3 replies
DTDrizzle Team
Created by mbe on 5/30/2024 in #help
unable to run drizzle studio
it seems to work fine pushing a migration but somehow drizzle kit studio seems to be unable to run
12 replies