drizzle-team / drizzle-team/drizzle-orm
[FEATURE]: with Recursive referential
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Describe what you want
Hello is there a possibility to have exhaustive recursive with statements or should this be a view?
```ts
export const postKind = pgEnum("post_kind", ["text", "image", "video"]);
export const post = pgTable(
"post",
{
id: serial("id").primaryKey(),
createdAt: timestamp("created_at")
.defaultNow()
.notNull(),
updatedAt: timestamp("updatedAt").defaultNow(),
body: text("body"),
kind: postKind("kind").notNull(),
// children: one to many
}
)
export const postRelations = relations(post, ({ one, many }) => ({
children: many(post),
// parent: one(Element),
}))
type PostTypeFirst = InferModel
export type PostType = PostTypeFirst & {
children?: PostType[]
}
//
db.query.post.findFirst({
where: (ele, { eq }) => (
eq(ele.id, input.id)
),
with: {
children: {
depth: 10 // or depth: 0 for exhaustive
},
},
});
```
thanks.
Contributor guide
Assessment
This issue has not been assessed yet.