import Surreal from 'surrealdb'; import { argv } from 'process'; import { User } from './user'; async function main() { // Extract username and password from command-line arguments const username = argv[2]; const password = argv[3]; if (!username || !password) { console.error('Usage: node main.ts <username> <password>'); process.exit(1); } const db = new Surreal(); // Connect to the local SurrealDB instance try { await db.connect("ws://localhost:8000"); await db.signin({ username: username, password: password }); await db.use({ namespace: 'ts_test', database: 'ts_test'}); const products = await db.select('product'); console.log('Products:'); products.forEach(product => { console.log(JSON.stringify(product, null, 2)); }); } catch (err) { console.error("Could not connect to db", err instanceof Error ? err.message : String(err)); } } main();