3.0.1 • Published 2 years ago

@joaomelo/collections v3.0.1

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
2 years ago

collections abstractions for firebase firestore.

tr;tl

at the application start desired collections are informed. the library will hold a global store with data and commands for each collection.

this stores are scoped to the current user while querying and setting.

getting started

to use it go like this.

// index.js
import { createCollections } from '@joaomelo/collections';
import { duplicateNote } from './notes';

const connection = { ... };
const configs = ['todos', { name: 'notes', commands: { duplicateNote } }]

const stores = createCollections({ connection, collections });

// later.js
const { notes } = stores;
notes.subscribe((items) => ...)
...
await notes.duplicateNote({ id: 'some-id' });

for each config you pass the lib will create a collection with:

  • the same collection's name
  • value property with an array of the collection records
  • subscribe method to observe updates
  • methods for commands: set, update and del and any custom one you pass. every custom command will have access to all stores as second parameter.

collections are rxjs subjects and can be used with that lib operators.