diff options
author | Liang Qi <liang.qi@qt.io> | 2016-12-25 18:28:32 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-12-25 18:35:38 +0100 |
commit | 9a272ad1854d744ea57296ba633b9d0dc19d1625 (patch) | |
tree | 096752ec339e18998517a4598f907e4b42b9403d /src/imports/localstorage/plugin.cpp | |
parent | 70c6b9639c53d2a530ccabd1395f561211c16fa4 (diff) | |
parent | d8a052bc6b0349045db3d43a373b09cb16b41a48 (diff) |
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts:
tools/qmlimportscanner/main.cpp
Change-Id: I01e17581f6691a03f83788773364d0cf96319514
Diffstat (limited to 'src/imports/localstorage/plugin.cpp')
-rw-r--r-- | src/imports/localstorage/plugin.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index ebffb07346..d3ea93c80a 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: |