@@ -50,17 +50,16 @@ It is also possible to directly execute SQL against the db:
5050``` typescript
5151interface ISQLite {
5252 open: (dbName : string , location ? : string ) => any ;
53- close: (dbName : string , location ? : string ) => any ;
53+ close: (dbName : string ) => any ;
5454 executeSql: (
5555 dbName : string ,
5656 query : string ,
5757 params : any [] | undefined
58- ) => {
59- status: 0 | 1 ; // 0 for correct execution
60- message: string ; // if status === 1, here you will find error description
61- rows: any [];
62- insertId? : number ;
63- };
58+ ) => QueryResult ;
59+ executeSqlBatch: (
60+ dbName : string ,
61+ commands : SQLBatchParams []
62+ ) => BatchExecutionResult ;
6463}
6564```
6665
7978}
8079```
8180
81+ Some query examples:
82+ ``` typescript
83+ let result = sqlite .executeSql (' myDatabase' , ' SELECT somevalue FROM sometable' );
84+ if (! result .status ) { // result.status undefined or 0 === sucess
85+ for (let i = 0 ; i < result .rows .length ; i ++ ) {
86+ const row = result .rows .item (i );
87+ console .log (row .somevalue );
88+ }
89+ }
90+
91+ result = sqlite .executeSql (' myDatabase' , ' UPDATE sometable set somecolumn = ? where somekey = ?' , [0 , 1 ]);
92+ if (! result .status ) { // result.status undefined or 0 === sucess
93+ console .log (` Update affected ${result .rowsAffected } rows ` );
94+ }
95+ ```
96+
97+ Bulkupdate allows transactional execution of a set of commands
98+ ``` typescript
99+ const commands = [
100+ [' CREATE TABLE TEST (id integer)' ],
101+ [' INSERT INTO TABLE TEST (id) VALUES (?)' , [1 ]]
102+ [' INSERT INTO TABLE TEST (id) VALUES (?)' , [2 ]]
103+ [' INSERT INTO TABLE TEST (id) VALUES (?)' , [[3 ], [4 ], [5 ], [6 ]]]
104+ ];
105+ const result = sqlite .executeSqlBatch (' myDatabase' , commands );
106+ if (! result .status ) { // result.status undefined or 0 === sucess
107+ console .log (` Batch affected ${result .rowsAffected } rows ` );
108+ }
109+ ```
110+
82111## JSI Cheatsheet
83112
84113If you want to learn how to make your own JSI module and also get a reference guide for all things C++/JSI you can buy my [ JSI/C++ Cheatsheet] ( http://ospfranco.gumroad.com/l/IeeIvl )
0 commit comments