0.0.1 • Published 6 years ago

storage-angular v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Storage NG

A fast and easy to use Angular storage module.

whenever i use Angular, i can't find a simple storage module at all, there are a variety of bugs in the popular storage repo, they won't solve any problem at all. these shit experiences made me create storage-angular, a plain and practical angular storage module.

Getting Started

  1. install: npm i storage-angular --save

  2. import to app.module.ts

  3. enjoy it 😄

Configuration

you can configure more options in app.module.ts:

@NgModule({
  imports: [
    // ...
    StorageModule.forRoot({
      type?: string,              // 'local' or 'session', default is 'local'
      silent?: boolean,           // error log switch, default is false
      databases?: string[],       // multi databases
    }),
  ]
  // ...
})
export class AppModule {
}

API

methoddescriptionexample
find(key: string): anyfind one keythis.storage.find('name')
has(key: string): booleanwhether the key existsthis.storage.has('name')
remove(key: string): voidremove a keythis.storage.remove('name')
insert(key: string, value: any): voidcreate a key, overlay the original valuethis.storage.insert('name', 'witt')
findAll(): {}return all values (object)this.storage.findAll()
updateAll(store: {}): voidupdate all values, incremental coverage, value will not be deletedthis.storage.updateAll({})
replaceAll(store: {}): voidlike 'updateAll', but the value will be deletedthis.storage.replaceAll({})
use(database: string): StorageServiceswitch to new databasethis.storage.use('foods').find('hot_dog')
destroy(database?: string): voiddelete all the values of the current databasethis.storage.destroy()
implode(): voiddelete all, includes other databasesthis.storage.implode()