0.0.40 • Published 3 years ago
ngx-indexed-database v0.0.40
Usage
NgxIndexedDatabase module
import { NgxIndexedDatabaseModule } from "ngx-indexed-database";
@NgModule({
...
imports: [ NgxIndexedDatabaseModule, ... ],
...
})
NgxIndexedDatabase service
import { NgxIndexedDatabaseService } from "ngx-indexed-database";
...
export class XYZComponent {
constructor(private _ngxIndexedDBService: NgxIndexedDBService) {}
}
const ngxIndexedDBService = NgxIndexedDBService.getInstance();
Create
import { IndexedDBKeysDataType, IndexedDBStoreSchema, NgxIndexedDatabaseService } from "ngx-indexed-database";
...
const dbName = 'ngx-indexed-database';
const storeName = 'users';
const storeSchema: IndexedDBStoreSchema = {
id: { primary: true, unique: true, datatype: IndexedDBKeysDataType.INTEGER },
user_name: { datatype: IndexedDBKeysDataType.STRING },
email: { datatype: IndexedDBKeysDataType.STRING },
};
this._ngxIndexedDBService.createStore(dbName, storeName, storeSchema);
Delete
import { IndexedDBKeysDataType, IndexedDBStoreSchema, NgxIndexedDatabaseService } from "ngx-indexed-database";
...
const dbName = 'ngx-indexed-database';
const storeName = 'users';
this._ngxIndexedDBService.deleteStore(dbName, storeName);
NgxIndexedDatabaseStoreOperations service
import { NgxIndexedDatabaseStoreOperationsService } from "ngx-indexed-database";
...
export class XYZComponent {
constructor(private _ngxIndexedDatabaseStoreOperationsService: NgxIndexedDatabaseStoreOperationsService) {}
}
upsert
const data = { id: 1, user_name: 'test123', email: 'test@test.com' };
this._ngxIndexedDatabaseStoreOperationsService.upsert(dbName, storeName, data);
delete
this._ngxIndexedDatabaseStoreOperationsService.delete(dbName, storeName, 1);
deleteBy
this._ngxIndexedDatabaseStoreOperationsService.deleteBy(dbName, storeName, "user_name", "test123");
clear
this._ngxIndexedDatabaseStoreOperationsService.clear(dbName, storeName);
find
this._ngxIndexedDatabaseStoreOperationsService.find(dbName, storeName, 1);
findBy
this._ngxIndexedDatabaseStoreOperationsService.findBy(dbName, storeName, "user_name", "test123");
findMany
this._ngxIndexedDatabaseStoreOperationsService.findMany(dbName, storeName, [1, 2, 3]);
findManyBy
this._ngxIndexedDatabaseStoreOperationsService.findManyBy(dbName, storeName, 'user_name', ['test123', 'test456']);
fetchAll
this._ngxIndexedDatabaseStoreOperationsService.fetchAll(dbName, storeName);
resetStores
this._ngxIndexedDatabaseStoreOperationsService.resetStores(dbName);
this._ngxIndexedDatabaseStoreOperationsService.resetStores(dbName, {
exclude: ['ABC']
});
this._ngxIndexedDatabaseStoreOperationsService.resetStores(dbName, {
only: ['DEF']
});
Enum
export enum IndexedDBKeysDataType {
STRING,
INTEGER,
OBJECT,
ARRAY,
BOOLEAN,
ANY
}
Interfaces
export interface IndexedDBStoreSchema {
[key: string]: {
primary?: boolean;
unique?: boolean;
datatype: IndexedDBKeysDataType
}
}
Author
0.0.40
3 years ago
0.0.37
3 years ago
0.0.38
3 years ago
0.0.39
3 years ago
0.0.36
3 years ago
0.0.35
3 years ago
0.0.34
3 years ago
0.0.33
3 years ago
0.0.32
3 years ago
0.0.31
3 years ago
0.0.30
3 years ago
0.0.29
3 years ago
0.0.28
3 years ago
0.0.27
3 years ago
0.0.26
3 years ago
0.0.25
3 years ago
0.0.24
3 years ago
0.0.23
3 years ago
0.0.22
3 years ago
0.0.21
3 years ago
0.0.20
3 years ago
0.0.19
3 years ago
0.0.18
3 years ago
0.0.17
3 years ago
0.0.16
3 years ago
0.0.15
3 years ago
0.0.14
3 years ago
0.0.13
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago
0.0.7
3 years ago
0.0.6
3 years ago
0.0.5
3 years ago
0.0.4
3 years ago
0.0.3
3 years ago
0.0.2
3 years ago