import dw from "./dw";
// Simple query
const result = await dw.sql("SELECT * FROM users LIMIT 10;");
// Result: [{ id: 'usr_d78as6bg', name: 'Bob' }]
// Create a table and insert data
await dw.sql(`
CREATE TABLE products (
id INTEGER PRIMARY KEY,
name VARCHAR,
price DECIMAL(10,2)
);
`);
await dw.sql(`
INSERT INTO products VALUES
(1, 'Laptop', 999.99),
(2, 'Mouse', 29.99),
(3, 'Keyboard', 79.99);
`);
// Query the data
const products = await dw.sql("SELECT COUNT(*) as total FROM products;");
console.log(products); // [{ total: '3' }]