https://github.com/offline-pixel/idb-lib
It is a fast and lightweight angular library without any dependencies. A developer can use it for implementing CRUD operations with indexedDb. It is not only fast and lightweight, It is easiest to implement in angular projects.
https://github.com/offline-pixel/idb-lib
angular angular8 angular9 idb indexed-db indexeddb npm storage
Last synced: 16 days ago
JSON representation
It is a fast and lightweight angular library without any dependencies. A developer can use it for implementing CRUD operations with indexedDb. It is not only fast and lightweight, It is easiest to implement in angular projects.
- Host: GitHub
- URL: https://github.com/offline-pixel/idb-lib
- Owner: offline-pixel
- License: mit
- Created: 2020-08-01T10:24:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-03T06:36:45.000Z (almost 6 years ago)
- Last Synced: 2025-04-15T19:45:41.646Z (about 1 year ago)
- Topics: angular, angular8, angular9, idb, indexed-db, indexeddb, npm, storage
- Language: JavaScript
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# IndexedDb | Angular
It is one of the lightweight(packed:~28KB) and fastest NPM without any dependencies. A developer can use it for implementing CRUD operations with indexedDb. It is not only fast and lightweight, It is easiest to implement in angular projects. It returns a promise either will resolve or reject. Any issue's/suggestion's can be raised via [github](https://github.com/offline-pixel/idb-lib).
## Future releases
Future releases of this library will include some out-of-the-box implementation and right now, we are looking for funding. Without funding our major builds are getting delayed.
## Installation
```
npm i idb-lib
```
## Usage
in your ```*.module.ts``` file
```javascript
import { IndexedDbService } from 'indexed-db';
@NgModule({
...
providers: [
IndexedDbService
],
...
})
```
#### 1. Create/Register/Fetch in indexedDb
in your ```*.component.ts``` file with ``` this.idb.stream() ```
```javascript
import { IndexedDbService } from 'indexed-db';
export class *Component {
res = {
name: 'main',
store: 'child'
}
constructor( private idb: IndexedDbService ) {
this.idb.stream(this.res).then(data => {
if ( data === undefined || data.length === 0 ) {
// Do something
return;
}
// Do something
});
}
}
```
#### 2. Add/Update record in indexedDb
in your ```*.component.ts``` file with ``` this.idb.updateDB() ```
```javascript
import { IndexedDbService } from 'indexed-db';
export class *Component {
res = {
name: 'main',
store: 'child',
key: 'uniqueValue',
data: yourData // { name, email, mob } ref: destructuring
}
constructor( private idb: IndexedDbService ) {
this.idb.updateDB(this.res).then(data => {
if ( data === undefined || data.length === 0 ) {
// Do something
return;
}
// Do something
});
}
}
```
#### 3. Delete a record in indexedDb
in your ```*.component.ts``` file with ``` this.idb.deleteId() ```
```javascript
import { IndexedDbService } from 'indexed-db';
export class *Component {
res = {
name: 'main',
store: 'child',
key: 'uniqueValue'
}
constructor( private idb: IndexedDbService ) {
this.idb.deleteId(this.res).then(data => {
if ( data === undefined || data.length === 0 ) {
// Do something
return;
}
// Do something
});
}
}
```
#### Note: **It rejects whenever an operation fails and returns an empty array without any error messages. However, ERP can requests for the same. Also, peerDependencies and devDependencies are listed in package.json**
## Donation
Keep this account funded for open-source contributions and it will fasten our processes for other libraries/project as well.
```paypal.me/dranolia```