docs: add lesson 7 step 3 SQL schema walkthrough
Build Android app / Build (push) Has been cancelled
Build iOS app / Build (push) Has been cancelled
Template Cleanup / Template Cleanup (push) Has been cancelled

This commit is contained in:
OpenClaw committed 2026-03-08 23:54:35 +08:00
1 parent adb722f728
commit a5120b3e8a
3 files changed
+385 -3

No files matched your search

@@ -0,0 +1,36 @@
CREATE TABLE cart_item (
product_id TEXT NOT NULL PRIMARY KEY,
title TEXT NOT NULL,
price REAL NOT NULL,
image_url TEXT NOT NULL,
quantity INTEGER NOT NULL,
updated_at INTEGER NOT NULL
);
selectAll:
SELECT *
FROM cart_item
ORDER BY updated_at DESC;
selectById:
SELECT *
FROM cart_item
WHERE product_id = ?;
insertOrReplace:
INSERT OR REPLACE INTO cart_item(
product_id,
title,
price,
image_url,
quantity,
updated_at
)
VALUES (?, ?, ?, ?, ?, ?);
deleteById:
DELETE FROM cart_item
WHERE product_id = ?;
deleteAll:
DELETE FROM cart_item;
@@ -0,0 +1,35 @@
CREATE TABLE shop_order (
order_id TEXT NOT NULL PRIMARY KEY,
total_price REAL NOT NULL,
status TEXT NOT NULL,
created_at INTEGER NOT NULL
);
CREATE TABLE order_item (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
order_id TEXT NOT NULL,
product_id TEXT NOT NULL,
title TEXT NOT NULL,
price REAL NOT NULL,
image_url TEXT NOT NULL,
quantity INTEGER NOT NULL
);
selectOrders:
SELECT *
FROM shop_order
ORDER BY created_at DESC;
insertOrder:
INSERT INTO shop_order(order_id, total_price, status, created_at)
VALUES (?, ?, ?, ?);
insertOrderItem:
INSERT INTO order_item(order_id, product_id, title, price, image_url, quantity)
VALUES (?, ?, ?, ?, ?, ?);
selectItemsByOrderId:
SELECT *
FROM order_item
WHERE order_id = ?
ORDER BY id ASC;