shot
shot
DTDrizzle Team
Created by shot on 7/17/2024 in #help
RangeError: Maximum call stack size exceeded on update and delete for small number of rows (10s)
I have the following two calls that return the same RangeError:
await db
.update(schema.cards)
.set({ redeemable: true })
.where(eq(schema.cards.contractAddress, vaultAddress))
.returning({ address: vaultAddress })
.catch((error) => {
console.error(error);
error(500);
});

await db
.delete(schema.cards)
.where(
and(
eq(schema.accounts.address, address),
eq(schema.cards.contractAddress, vaultAddress),
),
)
.returning({ address })
.catch((error) => {
console.error(error);
error(500);
});
await db
.update(schema.cards)
.set({ redeemable: true })
.where(eq(schema.cards.contractAddress, vaultAddress))
.returning({ address: vaultAddress })
.catch((error) => {
console.error(error);
error(500);
});

await db
.delete(schema.cards)
.where(
and(
eq(schema.accounts.address, address),
eq(schema.cards.contractAddress, vaultAddress),
),
)
.returning({ address })
.catch((error) => {
console.error(error);
error(500);
});
The number of rows in question is around 10. I am successfully using .where with update in another query.
47 replies
DTDrizzle Team
Created by shot on 6/21/2024 in #help
query with one to many (postgres + foreign keys)
I have the following schema:
export const accounts = pgTable("accounts", {
id: serial("id").primaryKey(),
address: text("address").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
points: integer("points").default(0).notNull(),
});

export const nfts = pgTable("nfts", {
id: serial("id").primaryKey(),
contractAddress: text("contract_address").notNull(),
tokenId: integer("token_id").notNull(),
accountId: integer("account_id").references(() => accounts.id)
});
export const accounts = pgTable("accounts", {
id: serial("id").primaryKey(),
address: text("address").notNull(),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
points: integer("points").default(0).notNull(),
});

export const nfts = pgTable("nfts", {
id: serial("id").primaryKey(),
contractAddress: text("contract_address").notNull(),
tokenId: integer("token_id").notNull(),
accountId: integer("account_id").references(() => accounts.id)
});
I am trying to query for a specific accounts and get all associated nfts with:
db.query.accounts.findFirst({
where: eq(accounts.address, "0xDEAD...BEEF"),
with: { nfts: true },
});
db.query.accounts.findFirst({
where: eq(accounts.address, "0xDEAD...BEEF"),
with: { nfts: true },
});
This results in the error: Invalid drizzle query. Do I have to use drizzles relations to associate nfts to accounts instead of just foreign keys in order to use db.query?
4 replies
DTDrizzle Team
Created by shot on 11/22/2023 in #help
Typescript errors following drizzle-kit quick start
Files and errors in comments I'm attempting to follow the drizzle-kit quick start. I am encountering 2 issues. When attempting to run index.ts with pnpm tsc src/index.ts I get typescript errors from inside the drizzle-orm library. When I attempt to run the resulting src/index.js file with node src/index.js it fails with errors.
5 replies