3.0.1 • Published 3 years ago
@joaomelo/collections v3.0.1
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
valueproperty with an array of the collection recordssubscribemethod to observe updates- methods for commands:
set,updateanddeland 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.