本文整理汇总了TypeScript中ionic-native.SQLite.openDatabase方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SQLite.openDatabase方法的具体用法?TypeScript SQLite.openDatabase怎么用?TypeScript SQLite.openDatabase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ionic-native.SQLite
的用法示例。
在下文中一共展示了SQLite.openDatabase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private navController: NavController, private platform: Platform) {
this.database = new SQLite();
this.database.openDatabase({name: "data.db", location: "default"}).then(() => {
//this.refresh();
}, (error) => {
console.log("ERROR: ", error);
});
}
示例2: tests
this.platform.ready().then(() => {
this.db.openDatabase({
name: 'test.db',
location: 'default' // the location field is required
}).then(() => {
this.db.executeSql('CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY AUTOINCREMENT, name Text, user_id Text, date TIMESTAMP)', {}).then((data) =>{
console.log("TESTS TABLE CREATED", JSON.stringify(data.res));
}, (error) => {
console.log("Error creating tests table", JSON.stringify(error.err));
});
this.db.executeSql('CREATE TABLE IF NOT EXISTS test_sections (id INTEGER PRIMARY KEY AUTOINCREMENT, section INTEGER, question TEXT, score TEXT, question_id INTEGER, test_id INTEGER, CONSTRAINT composite_id UNIQUE (section, question_id, test_id))', {}).then((data) =>{
console.log("TEST SECTIONS TABLE CREATED", JSON.stringify(data.res));
}, (error) => {
console.log("Error creating tests table", JSON.stringify(error.err));
});
}, (err) => {
console.error('Unable to open database: ', err);
});
});
示例3: openDatabase
openDatabase(){
return this.db.openDatabase({
name: 'data.db',
location: 'default'
});
}