本文整理匯總了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'
});
}