Update node README.md so it runs on first copy/paste

- Give printQuery's params a default
- Top level awaits not always supported and not needed here
- Fix "head" of third query so it doesn't throw an arity mismatch
main
Sean Lynch 9 months ago committed by GitHub
parent 870f1e733f
commit 5990134818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,15 +23,15 @@ const {CozoDb} = require('cozo-node')
const db = new CozoDb() const db = new CozoDb()
function printQuery(query, params) { function printQuery(query, params = {}) {
return db.run(query, params) return db.run(query, params)
.then(data => console.log(data)) .then(data => console.log(data))
.catch(err => console.error(err.display || err.message)) .catch(err => console.error(err.display || err.message))
} }
await printQuery("?[] <- [['hello', 'world!']]") printQuery("?[] <- [['hello', 'world!']]")
await printQuery("?[] <- [['hello', 'world', $name]]", {"name": "JavaScript"}) printQuery("?[] <- [['hello', 'world', $name]]", {"name": "JavaScript"})
await printQuery("?[a] <- [[1, 2]]") printQuery("?[a, b] <- [[1, 2]]")
``` ```
### Basic API ### Basic API

Loading…
Cancel
Save