本文整理匯總了TypeScript中ionic-framework/ionic.SqlStorage類的典型用法代碼示例。如果您正苦於以下問題:TypeScript SqlStorage類的具體用法?TypeScript SqlStorage怎麽用?TypeScript SqlStorage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SqlStorage類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: removeClicker
public removeClicker(id: string): void {
// remove clicker from the service
this.clickers = this.clickers.filter((clicker: Clicker) => { return clicker.getId() !== id; });
// remove from ids array
this.ids = this.ids.filter((filterId: string) => { return filterId !== id; });
// null id in db
this.storage.remove(id);
// update service's ids array
this.storage.set('ids', JSON.stringify(this.ids));
}
示例2: newClicker
public newClicker(name: string): string {
const id: string = this.uid();
const clicker: Clicker = new Clicker(id, name);
// add the clicker to the service
this.clickers.push(clicker);
// add the id to the service (need to keep a separate reference of IDs so we can cold load clickers)
this.ids.push(id);
// save the clicker by id
this.storage.set(id, JSON.stringify(clicker));
// save the service's ids array
this.storage.set('ids', JSON.stringify(this.ids));
return id;
}
示例3: newTask
public newTask(name: string): string {
const id: string = this.uid();
// by default time is set to 300
const task: Task = new Task(id, name, 300);
// add the task to the service
this.tasks.push(task);
// add the id to the service (need to keep a separate reference of IDs so we can cold load clickers)
this.ids.push(id);
// save the clicker by id
this.storage.set(id, JSON.stringify(task));
// save the service's ids array
this.storage.set('ids', JSON.stringify(this.ids));
return id;
}
示例4: Promise
return new Promise((resolve: Function) => {
let ids: Array<string> = [];
this.storage.get('ids') // return the promise so we can chain initClickers
.then((rawIds: string) => {
// ids are stored as stringified JSON array
ids = JSON.parse(rawIds) || [];
})
.then(() => resolve(ids));
});
示例5: Promise
return new Promise((resolve: Function) => {
let tasks: Array<Task> = [];
for (let id of ids) {
this.storage.get(id)
.then((task: string) => {
tasks.push(this.initTask(task));
});
}
resolve(tasks);
});
示例6: doClick
public doClick(id: string): void {
const clicker: Clicker = this.getClicker(id);
clicker.doClick();
// save the clicker with updated click in storage
this.storage.set(clicker.getId(), JSON.stringify(clicker));
}