Monorepo containing core modules of Zeichen.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

28 行
691 B

  1. import Storage, { Collection } from '../core/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. }