From 499dc88af196c74afef1e2990c91bdd0a9e15294 Mon Sep 17 00:00:00 2001 From: ThomasTJdev Date: Thu, 13 May 2021 18:36:53 +0200 Subject: [PATCH] update readme --- README.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 960135f..5e33eb7 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,12 @@ otherwise a NULL value (``dbNullVal``) will be used. ``dbValOrNull()`` accepts all types due to `value: auto`. +## Auto NULL-values + +There are two generators, which can generate the `NULL` values for you. + +* `genArgs` does only set a field to `NULL` if `dbNullVal`/`dbValOrNull()` is passed. +* `genArgsSetNull` sets empty field (`""` / `c.len() == 0`) to `NULL`. ## Executing DB commands @@ -50,12 +56,6 @@ The examples below support the various DB commands such as ``exec``, All the examples uses a table named: ``myTable`` and they use the WHERE argument on: ``name``. -## genArgs / genArgsSetNull - -* `genArgs` does only set a field to `NULL` if `dbNullVal` is passed. -* `genArgsSetNull` sets empty field to `NULL`. - - ## Update string & int ### Version 1 @@ -76,6 +76,14 @@ All the examples uses a table named: ``myTable`` and they use the WHERE argument ``` +### Version 3 +```nim + let a = genArgsSetNull("em@em.com", "", "John") + exec(db, sqlUpdate("myTable", ["email", "age"], ["name"], a.query), a.args) + # ==> string, NULL + # ==> UPDATE myTable SET email = ?, age = NULL WHERE name = ? +``` + ## Update NULL & int