Releases: mesqueeb/vuex-easy-firestore
v1.37.0
Since 1.37.0 vuex-easy-firestore now requires Firebase 9.x as peer dependency.
It imports and relies on the compat
libraries provided by Firebase 9.x.
Future versions
Maintenance on vuex-easy-firestore
from me is now deprecated in favour of the new library I wrote from scratch.
I still accept PRs of course.
Changelog
openDBChannel improvement + new fetch* actions syntax 🔍
We've completely re-written the openDBChannel action, so it's now much better at reporting and handling errors!
openDBChannel
now gets an option and resolves its promise with an objects that allow new features, in the form:
dispatch('moduleName/openDBChannel', {includeMetadataChanges: boolean})
.then(({refreshed, streaming, stop}) => { })
.catch(error => {...})
You must take the streaming
promise into account to catch errors in the channel.
See the openDBChannel documentation for more info.
There is also a slightly new syntax for fetch
, fetchById
and openDBChannel
, although the old syntax will keep working until the next major version.
Before:
dispatch('moduleName/fetch', { where: [...], orderBy: [...], limit: [...], userId: '...', otherPathVariable: '...', someOption: '...' })
This has become:
dispatch('moduleName/fetch', {
clauses: { where: [...], orderBy: [...], limit: [...] },
pathVariables: { userId: '...', otherPathVariable: '...' },
someOption: '...'
})
better Error handling for actions 📌
Now any action will properly catch errors from firebase and reject them like any other normal API
// any of these:
dispatch('module/set', {id, data})
dispatch('module/patch', {id, data})
dispatch('module/insert', {data})
dispatch('module/delete', id)
// can now use:
.then(id => console.log(id))
.catch(e => console.error(e))
And also for the batch actions:
// any of these:
dispatch('module/patchBatch', {doc, ids})
dispatch('module/insertBatch', docs)
dispatch('module/deleteBatch', ids)
// can now use:
.then(ids => console.log(ids))
.catch(e => console.error(e))
Please mind that before v1.35.0 this would only take a split millisecond:
// even though this is a promise:
const newId = await dispatch('module/insert', newDoc)
// it gets resolved with the new ID almost immediately
But now it will wait for the debounce timer (1 sec by default) before it's resolved.
const newId = await dispatch('module/insert', newDoc)
const newId2 = await dispatch('module/insert', newDoc)
const newId3 = await dispatch('module/insert', newDoc)
// these all get resolved when the 1 sec debounce timer finishes
There were further no breaking changes besides the fact that resolving this promise now takes as long as the debounce timer.
Fetch by id 🎣
NEW ☘️
Now Vuex Easy Firestore supports fetching a single document by id to have it automatically added to your 'collection' module.
See the updated documentation here on how to use it!
Enjoy!! 🍻
increment me 🏓
NEW ☘️
Now Vuex Easy Firestore supports incrementing values just like Firebase can with Firebase.firestore.FieldValue.increment
.
See the documentation here on how to use it!
Fixes 🖍
Fixed #188 (When reloading an app in offline mode any collections that had pending updates would not populate into Vuex)
Enjoy!! 🌸
Spring has come 🌱
Some quality of life updates have been integrated over the past couple of weeks.
NEW ☘️
- Multiple values arrayUnion arrayRemove 🌬 #183 #177
- Prevent initial doc insert ('doc' mode) #107 (see documentation)
- Customize debounce time between firestore calls #146 (see documentation)
Fixes 🐾
Enjoy!! 🌴
Important bug fixes! ‼️
I was able to tackle some very tricky bugs related to ArrayUnion and userId in the firestore path!
Updating to this version is recommended for ALL users!!!
Enjoy!! 🔆
Hooks behaviour change 📎
I have had a breakthrough concerning hooks!
Previously vuex-easy-firestore used FieldValue.serverTimestamp()
for the default fields "updated_at" and "created_at". However, the problem was that a serverTimestamp
makes the hooks execute a "server" change even on a "local" change!
By changing these fields to just use a regular new Date()
a "server change" is not triggered at all and thus the Hooks have become much more usable! 🎉
The change is not really a "breaking" change, because even before, on a serverChange.modifiedHook
there was no changed data anyway, but nevertheless, if you used hooks before it's important to know the change in behaviour:
dispatch('module/set', {id, field: 'new value'})
Before: because of the "updated_at" field, this would trigger:
- sync.patchHook
- serverChange.modifiedHook
Now: it only triggers:
- sync.patchHook
Please review the "execution timing of hooks" which is now greatly simplified!
Enjoy!!! 🌋
Docs & fetchAndAdd 🌸
Completely rewrote the documentation to be more similar to the Firestore documentation. This makes it easier to navigate and especially for new people everything will make sense.
The main part that was updated was the "query data" section.
Now it's really clear what the difference is between openDBChannel
and fetchAndAdd
. Made also improvements to fetchAndAdd
so it's a first class citizen, just as useful as openDBChannel!
Enjoy!! ☀️
Default values improved! 🎄
All new default values!
Now the library can apply default values on local changes and before a doc is inserted into your vuex module and synced!
Documentation is fully updated.
Before vs now
Before default values were defined in serverChange.defaultValues
but now that it also applies on local changes it is changed to sync.defaultValues
. Please note that backwards capability was built in, so there are no breaking changes!
closes issues
- [Feature] defaultValues applied on
insert
#48 - [Bug] patching a doc < 1000ms after insert fails #103
- optimisation planned for fetchAndAdd & setting pathVariable #100 (just need to update docs)
Enjoy!!! 🌚