mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
feat(storage): support deletion of multiple entries
This commit is contained in:
@@ -104,7 +104,7 @@ describe('StorageProvider', () => {
|
|||||||
expect(Array.from(entries.keys()).sort()).toEqual(['bar', 'foo', 'foo.bar']);
|
expect(Array.from(entries.keys()).sort()).toEqual(['bar', 'foo', 'foo.bar']);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete one entry', async () => {
|
it('should delete one or more entries from the storage', async () => {
|
||||||
spyOn(storage, 'remove').and.callThrough();
|
spyOn(storage, 'remove').and.callThrough();
|
||||||
await storageProvider.putMultiple(sampleEntries);
|
await storageProvider.putMultiple(sampleEntries);
|
||||||
let entries = await storageProvider.getAll();
|
let entries = await storageProvider.getAll();
|
||||||
@@ -114,6 +114,9 @@ describe('StorageProvider', () => {
|
|||||||
expect(storage.remove).toHaveBeenCalled();
|
expect(storage.remove).toHaveBeenCalled();
|
||||||
entries = await storageProvider.getAll();
|
entries = await storageProvider.getAll();
|
||||||
expect(Array.from(entries.values())).toEqual(['Bar', 123]);
|
expect(Array.from(entries.values())).toEqual(['Bar', 123]);
|
||||||
|
|
||||||
|
await storageProvider.delete('foo', 'foo.bar');
|
||||||
|
expect(await storageProvider.length()).toBe(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete all entries in the storage', async () => {
|
it('should delete all entries in the storage', async () => {
|
||||||
|
|||||||
@@ -81,12 +81,14 @@ export class StorageProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a storage entry using the key used to save it
|
* Deletes storage entries using keys used to save them
|
||||||
*
|
*
|
||||||
* @param key Unique identifier of the resource
|
* @param keys Unique identifiers of the resources for deletion
|
||||||
*/
|
*/
|
||||||
async delete(key: string): Promise<void> {
|
async delete(...keys: string[]): Promise<void> {
|
||||||
return this.storage.remove(key);
|
await keys.forEach((key) => {
|
||||||
|
this.storage.remove(key);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user