What is your schema? What is the query? Types?
What is your schema? What is the query? Types?
await env.DB.prepare("SELECT * FROM products WHERE amazonAsin = ?").bind(amazonAsin).first() ... It is not typed. My schema is like the following:but it happens as soon as realistic traffic is sent to wranger, and other tables and other types of queries happen at the same time.What kind of query volume (in QPS) - ?
wrangler d1 execute to run an SQL query, will this query be all in one db transaction, even if there are multiple udates, inserts and deletes in there?results, so you'll need to make the second call const { results: countResults...
countResults isn't a property of results and so it'll always be undefined if it doesn't exist on the object.Each destructured property can have a default value. The default value is used when the property is not present, or has value undefined. It is not used if the property has value null.
await env.DB.prepare("SELECT * FROM products WHERE amazonAsin = ?").bind(amazonAsin).first()wrangler d1 executeresultsresultsconst { results: countResults...countResultsCREATE TABLE publishers
(
`id` INTEGER PRIMARY KEY,
`name` TEXT NOT NULL,
`dateRecorded` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`isDifficult` BOOLEAN NOT NULL DEFAULT 0
);
CREATE INDEX idx_publishers_name ON publishers (name);
CREATE TABLE products
(
`id` INTEGER PRIMARY KEY,
`name` TEXT NOT NULL,
`publisherId` INTEGER NOT NULL,
`amazonAsin` TEXT UNIQUE,
`dateSeen` TEXT NOT NULL,
`publisherApprovalStatus` TEXT NOT NULL DEFAULT 'pending',
`sellable` BOOLEAN NOT NULL DEFAULT 0,
`lastSalesRank` INTEGER,
`lastSalesRankDate` DATETIME, bookPublishingDate DATETIME,
FOREIGN KEY (publisherId) REFERENCES publishers (id) ON DELETE CASCADE
);
CREATE INDEX idx_products_publisherId ON products (publisherId);
CREATE INDEX idx_products_amazonAsin ON products (amazonAsin);
CREATE INDEX idx_products_publisherApprovalStatus ON products (publisherApprovalStatus);
CREATE INDEX idx_products_sellable ON products (sellable);
CREATE INDEX idx_products_lastSalesRank ON products (lastSalesRank);