本文整理汇总了TypeScript中ionic-native/dist/index.SQLite类的典型用法代码示例。如果您正苦于以下问题:TypeScript SQLite类的具体用法?TypeScript SQLite怎么用?TypeScript SQLite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SQLite类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(private nav: NavController, private menu: MenuController) {
// this.trololo = "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAA4VSURBVFhHnVlZbJxXGT3/7ItntT22YzuOndhu3CxOWpwuNKUlLS1NqUClBYRaISFe+oJQJd4rJN6RQICEEC+UByi0VTd1SxeXtikJNInjLI3t2B6PZ2zPeMazb5xzJw4pTbp9yZ+Z+ee/9557vu8733cnVpOGL2HVahWbQwuFAtbX11EsFs1nv9+PUCgEt9ttPttsNjidTvP+i9oXAliv15HNZmFZFlKpFCrlCmKxTnTGYpee+J816jUsLCwivrSEaDSK9vZ2c1/vNf7z2ucGGI/HzWuZoNqjYQRDYSKuYW4piWRmA7lSFdUG2UITHocNkTYv+mIRhMN8jra4sIBiqWTeBwIBdHV1mfefZZ8JsFar4dy5c2bnbpcT4UgY52Yu4s0Ts/h3PI183Y5CpYFKrY46n7cI0GHZ4HHZ4XNaiHltODjSg6/uGYavrQ1L8YTxxCI3fODAgdYin2KfCjCTyRhXhhlPHdEQ5haX8Zvn38OpNYJxuFBvWHASiMNuJ3MWiIu+5aY4ZaXeQJ1x2uCrm4y2NQt4cF8/vn1wP5o2O5aTqwyBBYyP74XP52steBW7JsBEIoEMA39LTzeqlQp+99wk/nYiiWhXN7xOO1x2G+x2C3bGk43vTVRxJk3X5nFioCMIG7+bSa4jvl5Eo9HEyvoGOpHD4/dP4IbhfhTL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pNUXer63OY9yRYsfuoCfDuPNrt2NsbMzMJfvEufj114/g9SNvGB06U/EjGxqC18/Dk4sNLDXOwcYgSAl56Mbt+AozWgIu0/Pqtl9hcrxPZgRCU8uN8oIqlKqLxNqEDfFW0wnsqC2iR30HG4X9+8Zx+PB9Zr5N+wRA2ZNPPonp6bPcIQ9RtQDWQtvMr1kOOlUdNsPM9H8HtsewjR2K2vZVNrPTiQwWefQUmUaACVLJplKoVyWaYk69ZTk5h6F6At0eaQQwPLQdjzz6SAvAFXZVgDoPPP3Ms9TGsyZBElUXLga2IxiNMQnYUROAGll1OCpder+pgQKvpkKfTOEXSLJoADIYNool2JMzGLFSCDr5HDV2bGwU9x8+bFz8/3ZVgDL9Yvrc88/j2LHjxn2FpgPnm1E0u0bgo5BzbjJFsHxWTa0KEu/oH5rKF7VUwFQteF+tW35lCZ3Z8+hzVzmeY9iUXr9zFA888IBRkqvZNQFu2muvvYa3J/+JVZ607EyANQpq3BlDM9IPhz9oejgbk8jiJYyaTE5rEpB+ZW00GG9rCQRyc9jqqFBrnSYO+/v7sGfXGO65516zzrXsMwHKpqenMfnue5g6NYU6G9wmm4osO5esPYCKO4S6y0+fs24yLlX1m9UyRY7tUiUHd3kdnQ62UC433UlJ8foxNDSAg7cdxOjo6KUVrm2fC6CsQOk5eeIETp+extTp00a4izzYSDpU6FUKG8xERZ8iUrEpOp3sSHS+8Ho92HnddRil3u7es/tTf7S80j43wE3TL/rLiQSWk0m8f/QDLC8nDHjFm9KRoWeA6WAuDe3t2YK943vRw9LV1d1t/gfgi9gXBnil6dCvo6F+T9EBR/8NoenEjn7n0+XSuZcy9OUM+C9FLnFDrTwRLQAAAABJRU5ErkJggg==') no-repeat left top";
this.database = new SQLite();
this.database.openDatabase({name: "data.db", location: "default"}).then(() => {
this.refresh();
}, (error) => {
console.log("ERROR: ", error);
});
}
示例2: constructor
constructor(public nav: NavController, private navParams: NavParams, private viewCtrl: ViewController) {
let messageId = navParams.get('id');
this.database = new SQLite();
this.database.openDatabase({name: "data.db", location: "default"}).then(() => {
this.database.executeSql("SELECT * FROM nachrichten WHERE id=?", [messageId]).then((data) => {
if(data.rows.length > 0) {
let d = new Date(data.rows.item(0).mTime*1000);
let day;
let month;
if ( d.getDay() < 10 )
day = '0'+d.getDay();
else
day = d.getDay();
if ( d.getDay() < 10 )
month = '0'+d.getMonth();
else
month = d.getMonth();
this.messageInfo.push({id: data.rows.item(0).id,
sender: data.rows.item(0).sender,
titel: data.rows.item(0).titel,
message: data.rows.item(0).message,
mTime: day + '.' + month + '.' + d.getFullYear(),
// gelesenColor: gelesenColor,
// iconName: iconName,
componentId: data.rows.item(0).id});
this.database.executeSql("UPDATE nachrichten SET gelesen=1 WHERE id=?", [messageId]).then((data) => {
console.log("Nachricht ist jetzt gelesen.");
}, (error) => {
console.log("Es ist eine Fehler aufgetrofen: diesen Nachricht kann nicht wie 'gelesen' markiert werden.");
});
}
}, (error) => {
// alert("6 ERROR: " + JSON.stringify(error));
});
}, (error) => {
console.log("ERROR: ", error);
});
}
示例3: Date
this.database.executeSql("SELECT * FROM nachrichten WHERE id=?", [messageId]).then((data) => {
if(data.rows.length > 0) {
let d = new Date(data.rows.item(0).mTime*1000);
let day;
let month;
if ( d.getDay() < 10 )
day = '0'+d.getDay();
else
day = d.getDay();
if ( d.getDay() < 10 )
month = '0'+d.getMonth();
else
month = d.getMonth();
this.messageInfo.push({id: data.rows.item(0).id,
sender: data.rows.item(0).sender,
titel: data.rows.item(0).titel,
message: data.rows.item(0).message,
mTime: day + '.' + month + '.' + d.getFullYear(),
// gelesenColor: gelesenColor,
// iconName: iconName,
componentId: data.rows.item(0).id});
this.database.executeSql("UPDATE nachrichten SET gelesen=1 WHERE id=?", [messageId]).then((data) => {
console.log("Nachricht ist jetzt gelesen.");
}, (error) => {
console.log("Es ist eine Fehler aufgetrofen: diesen Nachricht kann nicht wie 'gelesen' markiert werden.");
});
}
}, (error) => {
示例4: refresh
public refresh() {
// this.trololo = 'red';
this.database.executeSql("SELECT * FROM nachrichten ORDER BY mTime DESC ", []).then((data) => {
this.people = [];
if(data.rows.length > 0) {
let gelesenColor;
let iconName;
let bgColor = 0;
let day;
let d;
let dateComp;
let todayD;
for(var i = 0; i < data.rows.length; i++) {
d = new Date(data.rows.item(i).mTime*1000);//*1000
dateComp = new Date(data.rows.item(i).mTime*1000);//*1000
dateComp.setHours(0,0,0,0);
todayD = new Date();
todayD.setHours(0,0,0,0);
gelesenColor = '#bababa';
iconName = 'ios-radio-button-off';
if ( todayD.getTime() == dateComp.getTime() )
day = this.oneMoreNull( d.getHours() ) + ':' + this.oneMoreNull( d.getMinutes() );
else
day = this.oneMoreNull( d.getDate() ) + '.' + this.oneMoreNull( d.getMonth() + 1 ) + '.' + d.getFullYear();
if ( data.rows.item(i).gelesen > 0 ) {
gelesenColor = "#f36f21";
iconName = 'ios-radio-button-on';
}
this.people.push({sender: data.rows.item(i).sender,
titel: data.rows.item(i).titel,
message: data.rows.item(i).message,
mTime: day,
gelesenColor: gelesenColor,
iconName: iconName,
componentId: data.rows.item(i).id,
bgColor: bgColor});
(bgColor === 0) ? bgColor=1 : bgColor=0;
}
}
}, (error) => {
// alert("6 ERROR: " + JSON.stringify(error));
});
}