本文整理汇总了TypeScript中ionic-native.SQLite类的典型用法代码示例。如果您正苦于以下问题:TypeScript SQLite类的具体用法?TypeScript SQLite怎么用?TypeScript SQLite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQLite类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
});
}
开发者ID:alejo8591,项目名称:charla-git,代码行数:8,代码来源:home.ts
示例2: tests
}).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) => {
开发者ID:alexandrastoica,项目名称:ionic2-dementia-test-app,代码行数:14,代码来源:sqlite.ts
示例3: add
public add() {
this.database.executeSql("INSERT INTO user (firstname, lastname) VALUES (?, ?)", ['Alejandro', 'Romero']).then((data) => {
console.log("INSERTED: " + JSON.stringify(data));
}, (error) => {
console.log("ERROR: " + JSON.stringify(error));
});
}
开发者ID:alejo8591,项目名称:charla-git,代码行数:7,代码来源:home.ts
示例4: createTable
createTable(){
let sql = 'CREATE TABLE IF NOT EXISTS product(' +
'id INTEGER PRIMARY KEY AUTOINCREMENT, ' +
'type TEXT, ' +
'quantity INTEGER, ' +
'price TEXT, ' +
'name TEXT)';
return this.db.executeSql(sql, []);
}
开发者ID:alejo8591,项目名称:charla-git,代码行数:9,代码来源:service.ts
示例5: getAll
getAll(){
let query = 'SELECT * FROM product';
return this.db.executeSql(query, [])
.then(response => {
let products = [];
for (let index = 0; index < response.rows.length; index++) {
products.push(response.rows.item(index));
}
return Promise.resolve(products);
})
}
开发者ID:alejo8591,项目名称:charla-git,代码行数:11,代码来源:service.ts
示例6: refresh
public refresh() {
this.database.executeSql("SELECT * FROM user", {}).then((data) => {
this.user = [];
if(data.rows.length > 0) {
for(var i = 0; i < data.rows.length; i++) {
this.user.push({firstname: data.rows.item(i).firstname, lastname: data.rows.item(i).lastname});
}
}
}, (error) => {
console.log("ERROR: " + JSON.stringify(error));
});
}
开发者ID:alejo8591,项目名称:charla-git,代码行数:12,代码来源:home.ts
示例7: deleteTestByUser
public deleteTestByUser(user_id: number) {
let sql = 'DELETE FROM tests WHERE user_id = ?';
return this.db.executeSql(sql, [user_id]);
}
开发者ID:alexandrastoica,项目名称:ionic2-dementia-test-app,代码行数:4,代码来源:sqlite.ts
示例8: update
// Update an existing note with a given ID
public update(test: Test) {
let sql = 'UPDATE test_sections SET score = ? WHERE section = ? AND question_id = ? AND test_id = ?';
return this.db.executeSql(sql, [test.score, test.section, test.question_id, test.test_id]);
}
开发者ID:alexandrastoica,项目名称:ionic2-dementia-test-app,代码行数:5,代码来源:sqlite.ts
示例9: deleteAnswers
public deleteAnswers(id: number){
let sql = 'DELETE FROM test_sections WHERE test_id = ?';
return this.db.executeSql(sql, [id]);
}
开发者ID:alexandrastoica,项目名称:ionic2-dementia-test-app,代码行数:4,代码来源:sqlite.ts
注:本文中的ionic-native.SQLite类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论