From c1f20d90362f2b61651db02097152e42d8378ff0 Mon Sep 17 00:00:00 2001 From: james Date: Sun, 10 Sep 2023 11:07:04 +0100 Subject: [PATCH] Fixed 'buildJsonObject' Fixed unescaped '$' --- readme.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 1c421e5..9725e0c 100644 --- a/readme.md +++ b/readme.md @@ -43,7 +43,7 @@ db.use("ns", "db") Creating a records ```kotlin // Create a record from a JSON object -db.create("user").content(buildJsonObject( put("username", "John"), put("password", "1234"))) +db.create("user").content(buildJsonObject{ put("username", "John"); put("password", "1234")}) // Create a record from a @Serializable object @Serializable @@ -99,8 +99,12 @@ db.delete("user") Querying records ```kotlin val result = db.query( - "SELECT * FROM user WHERE username = $username AND password = $password\n" + - "ORDER BY username;", + """ + SELECT * + FROM user + WHERE username = $username AND password = $password + ORDER BY username; + """, bind("username", "John"), bind("password", "1234") ) @@ -141,8 +145,10 @@ assert(post.author.id == "user:123") // You can fetch a record from a reference val queryResult = query( - "SELECT * FROM post WHERE author = $author\n" + - "FETCH author LIMIT 1;", + """ + SELECT * FROM post WHERE author = $author + FETCH author LIMIT 1; + """, bind("author", "John") ) val post = queryResult.first().data>()[0]