本文整理汇总了TypeScript中ionic-angular.SqlStorage类的典型用法代码示例。如果您正苦于以下问题:TypeScript SqlStorage类的具体用法?TypeScript SqlStorage怎么用?TypeScript SqlStorage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqlStorage类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
});
示例4: Promise
return new Promise((resolve: Function) => {
let clickers: Array<Clicker> = [];
for (let id of ids) {
this.storage.get(id)
.then((clicker: string) => {
clickers.push(this.initClicker(clicker));
});
}
resolve(clickers);
});
示例5: 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));
}
示例6: remove
public remove(key: string): Promise<{}> {
return this.storage.remove(key);
}
示例7: set
public set(key: string, value: string): Promise<{}> {
return this.storage.set(key, value);
}
示例8: get
public get(key: string): Promise<{}> {
return this.storage.get(key);
}