aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports/localstorage
diff options
context:
space:
mode:
authorNico Vertriest <nico.vertriest@qt.io>2016-11-09 14:52:41 +0100
committerNico Vertriest <nico.vertriest@theqtcompany.com>2016-12-20 09:44:01 +0000
commit0577aa9fd2808d24631ae03a9e3cbe6326be20e6 (patch)
tree4c04f35d4ef3452ecb9f8d5f0a5af1a01da28c38 /src/imports/localstorage
parent16c81bb0d493af00bc376784bcb7e03a4a037b04 (diff)
Doc: added support for JSON in localstorage documentation
Added examples on how to store in JSON format Change-Id: Ief58e28d42cd87cc0829e9265670e7c7bbdbeffe Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/imports/localstorage')
-rw-r--r--src/imports/localstorage/plugin.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index cd6d37ea5a..6704283cb9 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -640,14 +640,32 @@ Below you will find an example of a database transaction which catches exception
\snippet qml/localstorage/dbtransaction.js 0
+In the example you can see an \c insert statement where values are assigned to the fields,
+and the record is written into the table. That is an \c insert statement with a syntax that is usual
+for a relational database. It is however also possible to work with JSON objects and
+store them in a table.
+
+Let's suppose a simple example where we store trips in JSON format using \c date as the unique key.
+An example of a table that could be used for that purpose:
+
+\snippet qml/localstorage/dbtransaction.js 3
+
+The assignment of values to a JSON object:
+
+\snippet qml/localstorage/dbtransaction.js 4
+
+In that case, the data could be saved in the following way:
+
+\snippet qml/localstorage/dbtransaction.js 5
+
\section3 db.readTransaction(callback(tx))
This method creates a read-only transaction and passed to \e callback. In this function,
-you can call \e executeSql on \e tx to read the database (with SELECT statements).
+you can call \e executeSql on \e tx to read the database (with \c select statements).
\section3 results = tx.executeSql(statement, values)
-This method executes a SQL \e statement, binding the list of \e values to SQL positional parameters ("?").
+This method executes an SQL \e statement, binding the list of \e values to SQL positional parameters ("?").
It returns a results object, with the following properties: