Monorepo containing core modules of Zeichen.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

28 rader
698 B

  1. import Storage, { Collection } from '../../core/src/storage'
  2. import Engine from './Engine'
  3. export default class RemoteStorage<T> implements Storage<T> {
  4. private readonly engine: Engine<T, Collection<T>>
  5. constructor(
  6. private ownerId: string,
  7. private baseUrl: string,
  8. private collectionId: string,
  9. ) {
  10. this.engine = new Engine(baseUrl)
  11. }
  12. async deleteItem(item: T) {
  13. return this.engine.removeItem(this.collectionId, item)
  14. }
  15. async queryItems() {
  16. const response = await this.engine.getCollection(this.collectionId) as Collection<T>;
  17. return response.items;
  18. }
  19. async saveItem(newItem: T) {
  20. return this.engine.setItem(this.collectionId, newItem)
  21. }
  22. }