From e743ed8487282203f2881750357870f4c7cc9eb7 Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Thu, 13 Oct 2022 16:03:46 +0200 Subject: [PATCH 1/3] add table for different ways on how to do interpolation --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 63ce6d68..8f333068 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,17 @@ sql` select "id" from "users" ``` +### Quick Primer + +Here's a quick oversight over all the ways do interpolation in a query template string. + +| Interpolation syntax | Usage | Example | +| ------------- | ------------- | ------------- | +| `${ sql`` }` | for one or more keywords or sql (fragments) | const orderClause = `sql`` ` ``order by age desc`` ` ``` | +| `${ sql(string) }` | for identifiers | `sql('table_name')` | +| `${ sql([] or {}, ...) }` | for helpers | `` | +| `${ 'somevalue' }` | for values | `sql``` | + ## Advanced query methods ### Cursors From aa871d1e7da8474a53b50976384109f3a2e9393b Mon Sep 17 00:00:00 2001 From: "Dido (Christoph Poelt)" Date: Thu, 13 Oct 2022 16:04:26 +0200 Subject: [PATCH 2/3] remove document args for .describe() `describe` does not seem to take any arguments --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f333068..21e462ff 100644 --- a/README.md +++ b/README.md @@ -423,7 +423,7 @@ await sql` ``` ### Query Descriptions -#### ```await sql``.describe([rows = 1], fn) -> Result[]``` +#### ```await sql``.describe() -> Result[]``` Rather than executing a given query, `.describe` will return information utilized in the query process. This information can include the query identifier, column types, etc. From b1aed8420e1248ae01a503c3092a8cf3cc980e0a Mon Sep 17 00:00:00 2001 From: ChristophP Date: Thu, 13 Oct 2022 16:21:28 +0200 Subject: [PATCH 3/3] Format table for interpolation primer --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 21e462ff..bb325b9a 100644 --- a/README.md +++ b/README.md @@ -339,16 +339,16 @@ sql` select "id" from "users" ``` -### Quick Primer +### Quick primer on interpolation -Here's a quick oversight over all the ways do interpolation in a query template string. +Here's a quick oversight over all the ways to do interpolation in a query template string: -| Interpolation syntax | Usage | Example | -| ------------- | ------------- | ------------- | -| `${ sql`` }` | for one or more keywords or sql (fragments) | const orderClause = `sql`` ` ``order by age desc`` ` ``` | -| `${ sql(string) }` | for identifiers | `sql('table_name')` | -| `${ sql([] or {}, ...) }` | for helpers | `` | -| `${ 'somevalue' }` | for values | `sql``` | +| Interpolation syntax | Usage | Example | +| ------------- | ------------- | ------------- | +| `${ sql`` }` | for keywords or sql fragments | ``sql`SELECT * FROM users ${sql`order by age desc` }` `` | +| `${ sql(string) }` | for identifiers | ``sql`SELECT * FROM ${sql('table_name')` `` | +| `${ sql([] or {}, ...) }` | for helpers | ``sql`INSERT INTO users ${sql({ name: 'Peter'})}` `` | +| `${ 'somevalue' }` | for values | ``sql`SELECT * FROM users WHERE age = ${42}` `` | ## Advanced query methods