From 5990134818b621ed3757e04a6ad64146c4212cfe Mon Sep 17 00:00:00 2001 From: Sean Lynch Date: Sat, 23 Dec 2023 19:21:09 -0800 Subject: [PATCH] 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 --- cozo-lib-nodejs/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cozo-lib-nodejs/README.md b/cozo-lib-nodejs/README.md index 0909743c..896fb52b 100644 --- a/cozo-lib-nodejs/README.md +++ b/cozo-lib-nodejs/README.md @@ -23,15 +23,15 @@ const {CozoDb} = require('cozo-node') const db = new CozoDb() -function printQuery(query, params) { +function printQuery(query, params = {}) { return db.run(query, params) .then(data => console.log(data)) .catch(err => console.error(err.display || err.message)) } -await printQuery("?[] <- [['hello', 'world!']]") -await printQuery("?[] <- [['hello', 'world', $name]]", {"name": "JavaScript"}) -await printQuery("?[a] <- [[1, 2]]") +printQuery("?[] <- [['hello', 'world!']]") +printQuery("?[] <- [['hello', 'world', $name]]", {"name": "JavaScript"}) +printQuery("?[a, b] <- [[1, 2]]") ``` ### Basic API