xFlaws
xFlaws
DTDrizzle Team
Created by xFlaws on 11/29/2024 in #help
No such column Error - Query help
I don't know how to subqueries in drizzle studio... if anyone can help with that, that'd be awesome 🙂
5 replies
DTDrizzle Team
Created by xFlaws on 11/29/2024 in #help
No such column Error - Query help
The latter, just returns []
5 replies
DTDrizzle Team
Created by xFlaws on 11/29/2024 in #help
No such column Error - Query help
No description
5 replies
DTDrizzle Team
Created by xFlaws on 11/29/2024 in #help
No such column Error - Query help
Schema
export const auctionItems = sqliteTable("auction_items", {
id: integer("id").primaryKey({ autoIncrement: true }),
item: text("item", { length: 255 }).notNull(),
trait: text("trait", { length: 255 }).notNull(),
rarity: text("rarity", { length: 255 }).notNull(),
guild: text("guild", { length: 255 }).notNull(),
expiration: text("timestamp")
.notNull()
.default(sql`current_timestamp`),
});

export const auctionBids = sqliteTable(
"auction_bids",
{
id: integer("id").primaryKey({ autoIncrement: true }),
itemId: integer("item_id").notNull(),
userName: text("user_name", { length: 255 }).notNull(),
userId: text("user_id", { length: 255 }).notNull(),
bidAmount: integer("bid_amount").notNull(),
useCase: text("use_case", { length: 255 }).notNull(),
deleted: integer("deleted", { mode: "boolean" }).notNull().default(false),
},
(t) => ({
unq: unique().on(t.itemId, t.userName),
}),
);
export const auctionItems = sqliteTable("auction_items", {
id: integer("id").primaryKey({ autoIncrement: true }),
item: text("item", { length: 255 }).notNull(),
trait: text("trait", { length: 255 }).notNull(),
rarity: text("rarity", { length: 255 }).notNull(),
guild: text("guild", { length: 255 }).notNull(),
expiration: text("timestamp")
.notNull()
.default(sql`current_timestamp`),
});

export const auctionBids = sqliteTable(
"auction_bids",
{
id: integer("id").primaryKey({ autoIncrement: true }),
itemId: integer("item_id").notNull(),
userName: text("user_name", { length: 255 }).notNull(),
userId: text("user_id", { length: 255 }).notNull(),
bidAmount: integer("bid_amount").notNull(),
useCase: text("use_case", { length: 255 }).notNull(),
deleted: integer("deleted", { mode: "boolean" }).notNull().default(false),
},
(t) => ({
unq: unique().on(t.itemId, t.userName),
}),
);
Relations
export const auctionBidsRelations = relations(auctionBids, ({ one }) => ({
auctionItem: one(auctionItems, {
fields: [auctionBids.itemId],
references: [auctionItems.id],
}),
}));

export const auctionItemsRelations = relations(auctionItems, ({ many }) => ({
bids: many(auctionBids),
}));
export const auctionBidsRelations = relations(auctionBids, ({ one }) => ({
auctionItem: one(auctionItems, {
fields: [auctionBids.itemId],
references: [auctionItems.id],
}),
}));

export const auctionItemsRelations = relations(auctionItems, ({ many }) => ({
bids: many(auctionBids),
}));
5 replies