Self referencing

I have schema:
export const categories = pgTable('categories',{
    id: integer('id').primaryKey(),
    name: varchar('name',{length: 255}),
    parent: integer('parent').references((): AnyPgColumn => categories.id)
});

export const categoriesOneRelations = relations(categories, ({ one }) => ({
    parent: one(categories, { fields: [categories.parent], references: [categories.id] }),
}));

export const categoriesManyRelations2 = relations(categories, ({ many }) => ({
    children: many(categories),
}));

Code:
const categories = await db.query.categories.findMany({
        with: {
            children: true
        },
    });

console.log('categories:', JSON.stringify(categories, null, 2));

after execute then throw exeception
drizzle-orm/alias-72a4082c.cjs:3541
            : new Error(`There are multiple relations between "${referencedTableTsName}" and "${relation.sourceTable[Table.Symbol.Name]}". Please specify relation name`);
              ^

Error: There are multiple relations between "categories" and "categories". Please specify relation name

Please help me!
Was this page helpful?