One-to-one relations
So, uh, I can't figure out why i keep getting this annoying message:
Here is a schema:
And here is a query variable:
P.S. I love that error message ._.
ERROR: could not identify an equality operator for type json at character 716.
ERROR: could not identify an equality operator for type json at character 716.
export const dungeon = pgTable('dungeon', {
id: serial('id').primaryKey(),
image: json('image'),
name: varchar('name', { length: 256 }),
gameId: integer('game_id').notNull().references(() => game.id, { onDelete: 'cascade' }),
bossId: integer('boss_id').references(() => boss.id, { onDelete: 'cascade' }),
});
export const boss = pgTable('boss', {
id: serial('id').primaryKey(),
hp: integer('hp'),
name: varchar('name', { length: 256 }),
image: json('image'),
});
export const dungeonRelations = relations(dungeon, ({ many, one }) => ({
monsters: many(monster),
gameId: one(game, { fields: [dungeon.gameId], references: [game.id] }),
boss: one(boss, { fields: [dungeon.bossId], references: [boss.id] }),
}));
export const dungeon = pgTable('dungeon', {
id: serial('id').primaryKey(),
image: json('image'),
name: varchar('name', { length: 256 }),
gameId: integer('game_id').notNull().references(() => game.id, { onDelete: 'cascade' }),
bossId: integer('boss_id').references(() => boss.id, { onDelete: 'cascade' }),
});
export const boss = pgTable('boss', {
id: serial('id').primaryKey(),
hp: integer('hp'),
name: varchar('name', { length: 256 }),
image: json('image'),
});
export const dungeonRelations = relations(dungeon, ({ many, one }) => ({
monsters: many(monster),
gameId: one(game, { fields: [dungeon.gameId], references: [game.id] }),
boss: one(boss, { fields: [dungeon.bossId], references: [boss.id] }),
}));
const dungeons = await db.query.dungeon.findMany({
where: eq(dungeon.gameId, id),
with: {
monsters: true,
boss: true, <-- Without this, query working perfectly fine, so...
},
});
const dungeons = await db.query.dungeon.findMany({
where: eq(dungeon.gameId, id),
with: {
monsters: true,
boss: true, <-- Without this, query working perfectly fine, so...
},
});
1 Reply
Problem solved by downloading 0.28.0 update