Kai Revona
Kai Revona
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
Now I want to use likes table for post and commnet. But i don''t know how to do. Please help me
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
Thank for help, it works
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
It return don't have enough information to infer relation
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
but planetscale db doesn't support foreign key, so i can't use the ref relations
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
yeah i will check that soon and reply you
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
It return don't have information time to infer relation
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
What are i missing: Schema and relations
import {
mysqlTable,
primaryKey,
timestamp,
varchar,
} from "drizzle-orm/mysql-core"
import { nanoid } from "nanoid"

export const comments = mysqlTable("comments", {
id: varchar("id", { length: 191 })
.primaryKey()
.$defaultFn(() => nanoid()),
userId: varchar("user_id", { length: 191 }).notNull(),
postId: varchar("post_id", { length: 191 }).notNull(),
parentId: varchar("parent_id", { length: 191 }),
message: varchar("message", { length: 191 }).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").onUpdateNow(),
})
export const commentsRelations = relations(comments, ({ one, many }) => ({
user: one(users, {
fields: [comments.userId],
references: [users.id],
}),
post: one(posts, {
fields: [comments.postId],
references: [posts.id],
}),
parent: one(comments, {
fields: [comments.parentId],
references: [comments.id],
}),
child: many(comments),
}))
import {
mysqlTable,
primaryKey,
timestamp,
varchar,
} from "drizzle-orm/mysql-core"
import { nanoid } from "nanoid"

export const comments = mysqlTable("comments", {
id: varchar("id", { length: 191 })
.primaryKey()
.$defaultFn(() => nanoid()),
userId: varchar("user_id", { length: 191 }).notNull(),
postId: varchar("post_id", { length: 191 }).notNull(),
parentId: varchar("parent_id", { length: 191 }),
message: varchar("message", { length: 191 }).notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").onUpdateNow(),
})
export const commentsRelations = relations(comments, ({ one, many }) => ({
user: one(users, {
fields: [comments.userId],
references: [users.id],
}),
post: one(posts, {
fields: [comments.postId],
references: [posts.id],
}),
parent: one(comments, {
fields: [comments.parentId],
references: [comments.id],
}),
child: many(comments),
}))
20 replies
DTDrizzle Team
Created by Kai Revona on 2/2/2024 in #help
Nested comment
my planetscale db does't support foreign key
20 replies
DTDrizzle Team
Created by Kai Revona on 2/1/2024 in #help
Auto delete record using timestamp
But i don't know how to do that
9 replies
DTDrizzle Team
Created by Kai Revona on 2/1/2024 in #help
Auto delete record using timestamp
thanks
9 replies
DTDrizzle Team
Created by Kai Revona on 2/1/2024 in #help
Auto delete record using timestamp
how to do that
9 replies
DTDrizzle Team
Created by Kai Revona on 1/18/2024 in #help
many-to-many selection as array
I use MySQL Planetscale. Please update my code with array aggregation, hashtagsToPosts is an array with joins
5 replies
DTDrizzle Team
Created by Kai Revona on 1/18/2024 in #help
many-to-many selection as array
Can you give me some array aggregation functions for my code
5 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
Thanks
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
What is SQL query
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
and
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
Please help me wth createdAt logic
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
I don't know about how to use createdAt
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
Create the id in the app and add it to id of schema when insert, select by that id, right
20 replies
DTDrizzle Team
Created by Kai Revona on 1/13/2024 in #help
Autogenerated default approach
How to get that
20 replies