Skip to content

Commit 20d9916

Browse files
committed
Update README.md
1 parent 2c2ba00 commit 20d9916

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,33 @@ Step 4. Add var SQLite = require('react-native-sqlite-storage') to your index.io
2323

2424
![alt tag](https://raw.github.com/andpor/react-native-sqlite-storage/master/instructions/require.png)
2525

26-
Step 5. Add JS application code to use SQLite API in your index.ios.js etc.
26+
Step 5. Add JS application code to use SQLite API in your index.ios.js etc. Here is some sample code. For full working example see index.ios.js
27+
28+
```javascript
29+
errorCB(err) {
30+
console.log("SQL Error: " + err);
31+
},
32+
33+
successCB() {
34+
console.log("SQL executed fine");
35+
},
36+
37+
openCB() {
38+
console.log("Database OPENED");
39+
},
40+
41+
var db = SQLite.openDatabase("test.db", "1.0", "Test Database", 200000, openCB, errorCB);
42+
db.transaction((tx) => {
43+
tx.executeSql('SELECT * FROM Employees a, Departments b WHERE a.department = b.department_id', [], (tx, results) => {
44+
console.log("Query completed");
45+
var len = results.rows.length;
46+
for (let i = 0; i < len; i++) {
47+
let row = results.rows.item(i);
48+
console.log(`Employee name: ${row.name}, Dept Name: ${row.deptName}`);
49+
}
50+
});
51+
});
52+
```
2753

2854
Enjoy!
2955

0 commit comments

Comments
 (0)