ngx-indexed-db 9.1.2 → 9.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -37
- package/bundles/ngx-indexed-db.umd.js +214 -163
- package/bundles/ngx-indexed-db.umd.js.map +1 -1
- package/esm2015/lib/ngx-indexed-db.js +25 -1
- package/esm2015/lib/ngx-indexed-db.meta.js +1 -1
- package/esm2015/lib/ngx-indexed-db.service.js +173 -141
- package/esm2015/utils/index.js +1 -5
- package/fesm2015/ngx-indexed-db.js +194 -143
- package/fesm2015/ngx-indexed-db.js.map +1 -1
- package/lib/ngx-indexed-db.d.ts +2 -0
- package/lib/ngx-indexed-db.meta.d.ts +1 -1
- package/lib/ngx-indexed-db.service.d.ts +10 -6
- package/ngx-indexed-db.metadata.json +1 -1
- package/package.json +1 -1
- package/utils/index.d.ts +2 -2
package/README.md
CHANGED
|
@@ -117,9 +117,9 @@ import { NgxIndexedDBService } from 'ngx-indexed-db';
|
|
|
117
117
|
|
|
118
118
|
We cover several common methods used to work with the IndexedDB
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
### add<T>(storeName: string, value: T, key?: any): Observable<T>
|
|
121
121
|
|
|
122
|
-
Adds new entry in the store and returns
|
|
122
|
+
Adds new entry in the store and returns item added
|
|
123
123
|
|
|
124
124
|
- @param storeName The name of the store to add the item
|
|
125
125
|
- @param value The entry to be added
|
|
@@ -140,27 +140,6 @@ this.dbService
|
|
|
140
140
|
|
|
141
141
|
_In the previous example I'm using undefined as the key because the key is configured in the objectStore as auto-generated._
|
|
142
142
|
|
|
143
|
-
#### addItem<T>(storeName: string, value: T, key?: any): Observable<T>
|
|
144
|
-
|
|
145
|
-
Adds new entry in the store and returns the new item
|
|
146
|
-
|
|
147
|
-
- @param storeName The name of the store to add the item
|
|
148
|
-
- @param value The entry to be added
|
|
149
|
-
- @param key The optional key for the entry
|
|
150
|
-
|
|
151
|
-
It publishes in the observable the item that was added
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
this.dbService
|
|
155
|
-
.addItem('people', {
|
|
156
|
-
name: `Bruce Wayne`,
|
|
157
|
-
email: `bruce@wayne.com`,
|
|
158
|
-
})
|
|
159
|
-
.subscribe((item) => {
|
|
160
|
-
console.log('item: ', item);
|
|
161
|
-
});
|
|
162
|
-
```
|
|
163
|
-
|
|
164
143
|
### bulkAdd<T>(storeName: string, values: T & { key?: any }[]): Observable<number[]>
|
|
165
144
|
|
|
166
145
|
Adds new entries in the store and returns its key
|
|
@@ -185,6 +164,20 @@ this.dbService
|
|
|
185
164
|
});
|
|
186
165
|
```
|
|
187
166
|
|
|
167
|
+
|
|
168
|
+
### bulkDelete(storeName: string, keys: Key[]): Observable<number[]>
|
|
169
|
+
|
|
170
|
+
Delete multiple items in the store
|
|
171
|
+
|
|
172
|
+
- @param storeName The name of the store to delete the items
|
|
173
|
+
- @param keys The entries keys to be deleted
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
this.dbService.bulkDelete('people', [5, 6]).subscribe((result) => {
|
|
177
|
+
console.log('result: ', result);
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
188
181
|
### bulkGet<T>(storeName: string, keys: Array<IDBValidKey>): Observable<T[]>
|
|
189
182
|
|
|
190
183
|
Retrieve multiple entries in the store
|
|
@@ -198,7 +191,7 @@ this.dbService.bulkGet('people', [1, 3, 5]).subscribe((result) => {
|
|
|
198
191
|
});
|
|
199
192
|
```
|
|
200
193
|
|
|
201
|
-
|
|
194
|
+
### update<T>(storeName: string, value: T, key?: any): Observable<T[]>
|
|
202
195
|
|
|
203
196
|
Updates the given value in the objectStore and returns all items from the store after update..
|
|
204
197
|
|
|
@@ -218,7 +211,7 @@ this.dbService
|
|
|
218
211
|
});
|
|
219
212
|
```
|
|
220
213
|
|
|
221
|
-
|
|
214
|
+
### updateByKey<T>(storeName: string, value: T, key: IDBValidKey): Observable<T>
|
|
222
215
|
|
|
223
216
|
Updates the given value in the objectStore and returns the item from the store after update..
|
|
224
217
|
|
|
@@ -238,7 +231,7 @@ this.dbService
|
|
|
238
231
|
});
|
|
239
232
|
```
|
|
240
233
|
|
|
241
|
-
|
|
234
|
+
### getByKey<T>(storeName: string, key: IDBValidKey): Observable<T>
|
|
242
235
|
|
|
243
236
|
Returns entry by key.
|
|
244
237
|
|
|
@@ -251,7 +244,7 @@ this.dbService.getByKey('people', 1).subscribe((people) => {
|
|
|
251
244
|
});
|
|
252
245
|
```
|
|
253
246
|
|
|
254
|
-
|
|
247
|
+
### getAll<T>(storeName: string): Observable<T[]>
|
|
255
248
|
|
|
256
249
|
Return all elements from one store
|
|
257
250
|
|
|
@@ -263,7 +256,7 @@ this.dbService.getAll('people').subscribe((peoples) => {
|
|
|
263
256
|
});
|
|
264
257
|
```
|
|
265
258
|
|
|
266
|
-
|
|
259
|
+
### getByIndex<T>(storeName: string, indexName: string, key: IDBValidKey): Observable<T>
|
|
267
260
|
|
|
268
261
|
Returns entry by index.
|
|
269
262
|
|
|
@@ -277,7 +270,7 @@ this.dbService.getByIndex('people', 'name', 'Dave').subscribe((people) => {
|
|
|
277
270
|
});
|
|
278
271
|
```
|
|
279
272
|
|
|
280
|
-
|
|
273
|
+
### createObjectStore(storeSchema: ObjectStoreMeta, migrationFactory?: () => { [key: number]: (db: IDBDatabase, transaction: IDBTransaction) => void }): void
|
|
281
274
|
|
|
282
275
|
Allows to crate a new object store ad-hoc
|
|
283
276
|
|
|
@@ -297,7 +290,7 @@ const storeSchema: ObjectStoreMeta = {
|
|
|
297
290
|
this.dbService.createObjectStore(storeSchema);
|
|
298
291
|
```
|
|
299
292
|
|
|
300
|
-
|
|
293
|
+
### count(storeName: string, keyRange?: IDBValidKey | IDBKeyRange): Observable<number>
|
|
301
294
|
|
|
302
295
|
Returns the number of rows in a store.
|
|
303
296
|
|
|
@@ -310,7 +303,18 @@ this.dbService.count('people').subscribe((peopleCount) => {
|
|
|
310
303
|
});
|
|
311
304
|
```
|
|
312
305
|
|
|
313
|
-
|
|
306
|
+
### deleteObjectStore(storeName: string): Observable<boolean>
|
|
307
|
+
|
|
308
|
+
Delete the store by name, return true or false.
|
|
309
|
+
|
|
310
|
+
- @param storeName The name of the store to query
|
|
311
|
+
|
|
312
|
+
```js
|
|
313
|
+
this.dbService.deleteObjectStore(this.storneNameToDelete);
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### delete<T>(storeName: string, key: Key): Observable<T[]>
|
|
317
|
+
|
|
314
318
|
|
|
315
319
|
Returns all items from the store after delete.
|
|
316
320
|
|
|
@@ -323,7 +327,7 @@ this.dbService.delete('people', 3).subscribe((allPeople) => {
|
|
|
323
327
|
});
|
|
324
328
|
```
|
|
325
329
|
|
|
326
|
-
|
|
330
|
+
### deleteByKey(storeName: string, key: Key): Observable<boolean>
|
|
327
331
|
|
|
328
332
|
Returns true if the delete completes successfully.
|
|
329
333
|
|
|
@@ -336,7 +340,7 @@ this.dbService.deleteByKey('people', 3).subscribe((status) => {
|
|
|
336
340
|
});
|
|
337
341
|
```
|
|
338
342
|
|
|
339
|
-
|
|
343
|
+
### openCursor(storeName: string, keyRange?: IDBKeyRange): Observable<Event>
|
|
340
344
|
|
|
341
345
|
Returns the open cursor event
|
|
342
346
|
|
|
@@ -355,7 +359,7 @@ this.dbService.openCursor('people', IDBKeyRange.bound("A", "F")).subscribe((evt)
|
|
|
355
359
|
});
|
|
356
360
|
```
|
|
357
361
|
|
|
358
|
-
|
|
362
|
+
### openCursorByIndex(storeName: string, indexName: string, keyRange: IDBKeyRange, mode?: DBMode): Observable<Event>
|
|
359
363
|
|
|
360
364
|
Open a cursor by index filter.
|
|
361
365
|
|
|
@@ -376,7 +380,7 @@ this.dbService.openCursorByIndex('people', 'name', IDBKeyRange.only('john')).sub
|
|
|
376
380
|
});
|
|
377
381
|
```
|
|
378
382
|
|
|
379
|
-
|
|
383
|
+
### getAllByIndex<T>(storeName: string, indexName: string, keyRange: IDBKeyRange): Observable<T[]>
|
|
380
384
|
|
|
381
385
|
Returns all items by an index.
|
|
382
386
|
|
|
@@ -390,7 +394,7 @@ this.dbService.getAllByIndex('people', 'name', IDBKeyRange.only('john')).subscri
|
|
|
390
394
|
});
|
|
391
395
|
```
|
|
392
396
|
|
|
393
|
-
|
|
397
|
+
### clear(storeName: string): Observable<boolean>
|
|
394
398
|
|
|
395
399
|
Returns true if successfully delete all entries from the store.
|
|
396
400
|
|
|
@@ -402,7 +406,7 @@ this.dbService.clear('people').subscribe((successDeleted) => {
|
|
|
402
406
|
});
|
|
403
407
|
```
|
|
404
408
|
|
|
405
|
-
|
|
409
|
+
### deleteDatabase(): Observable<boolean>
|
|
406
410
|
|
|
407
411
|
Returns true if successfully delete the DB.
|
|
408
412
|
|