|
- import Storage, { Collection } from '../core/storage'
- import Engine from './Engine'
-
- export default class RemoteStorage<T> implements Storage<T> {
- private readonly engine: Engine<T, Collection<T>>
-
- constructor(
- private ownerId: string,
- private baseUrl: string,
- private collectionId: string,
- ) {
- this.engine = new Engine(baseUrl)
- }
-
- async deleteItem(item: T) {
- return this.engine.removeItem(this.collectionId, item)
- }
-
- async queryItems() {
- const response = await this.engine.getCollection(this.collectionId) as Collection<T>;
- return response.items;
- }
-
- async saveItem(newItem: T) {
- return this.engine.setItem(this.collectionId, newItem)
- }
- }
|