This repository has been archived by the owner on Sep 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
SQLiteDemo.js
87 lines (55 loc) · 2.43 KB
/
SQLiteDemo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
if (Meteor.isClient) {
Template.hello.helpers({
});
Template.hello.events({
'click .sqlite':function(){
testDB();
}
});
function testDB() {
//------------------------------------注----意---------------------------------------
//-------------------------在iOS中,数据库文件必须放在www目录下-------------------------
//-----在Xcode中,先将数据库文件放在Meteor项目的 “/Staging/www/” 目录下,部署程序即可-----
//----------------------------------------------------------------------------------
var db = window.sqlitePlugin.openDatabase({name: "bible.db", createFromLocation: 1});
db.transaction(function(tx) {
//单次查询BibleID表
var strSQL = "select SN as sn, ChapterNumber as chapternumber, FullName as fullname from BibleID;";
tx.executeSql(strSQL, [],
function(tx, res) {
//显示sql语句
console.log(strSQL);
console.log(" | " + "BibleID Table" + " | " + "SN" + " | " + "ChapterNumber" + " | " + "FullName");
//循环显示结果
for(var i=0;i<res.rows.length;i++)
{
console.log(" | " + res.rows.item(i).sn + " | " + res.rows.item(i).chapternumber + " | " + res.rows.item(i).fullname);
}
//查询结果的数量
console.log("查询结果: " + res.rows.length + " 个");
}, function(e) {
console.log("ERROR: " + e.message);
});
//单次查询Bible表
var strSQL = "select ID as id, Lection as lection from Bible where VolumeSN=1 and ChapterSN=1 order by ID;";
tx.executeSql(strSQL, [],
function(tx, res) {
//显示sql语句
console.log(strSQL);
console.log(" | " + "Bible Table" + " | " + "ID" + " | " + "Lection");
for(var i=0;i<res.rows.length;i++)
{
console.log(" | " + res.rows.item(i).id + " | " + res.rows.item(i).lection);
}
console.log("查询结果: " + res.rows.length + " 个");
}, function(e) {
console.log("ERROR: " + e.message);
});
});
}
}
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
}