Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions src/module/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,22 +447,19 @@ export default function (Firebase: any): AnyObject {
})
},
async fetchById ({ dispatch, getters, state }, id) {
try {
if (!id) throw 'missing-id'
if (!getters.collectionMode) throw 'only-in-collection-mode'
const ref = getters.dbRef
const _doc = await ref.doc(id).get()
if (!_doc.exists) {
if (state._conf.logging) {
throw `Doc with id "${id}" not found!`
}
if (!id) throw 'missing-id'
if (!getters.collectionMode) throw 'only-in-collection-mode'
const ref = getters.dbRef
const _doc = await ref.doc(id).get()
if (!_doc.exists) {
if (state._conf.logging) {
return logError(`Doc with id "${id}" not found!`)
}
const doc = getters.cleanUpRetrievedDoc(_doc.data(), id)
dispatch('applyHooksAndUpdateState', { change: 'added', id, doc })
return doc
} catch (e) {
return logError(e)
throw `Doc with id "${id}" not found!`
}
const doc = getters.cleanUpRetrievedDoc(_doc.data(), id)
dispatch('applyHooksAndUpdateState', { change: 'added', id, doc })
return doc
},
applyHooksAndUpdateState (
// this is only on server retrievals
Expand Down