Document.update -- Uncaught (in promise) Error: Invalid JSON payload received. Unknown name "currentDocument" at 'document': Cannot find field.
tervay opened this issue · 6 comments
Attempting to do the following in Firestore:
- check if
users/{userId}
document exists. if it does, skip to step 3, if not, go to step 2 - create
users/{userId}
with the base state{ id: ... , configs: []}
- retrieve
users/{userId}
'sconfig
array - Append an object to said array
Right now, my code looks a bit like this:
const userRef = db.reference(`users/${user}`)
const res = userRef.get()
.then((r) => {
// User is found!
return r;
}).catch((e) => {
// User not found. Creating
userRef.set({
id: user,
configs: []
})
return userRef
}).then((r) => {
// Append new object to configs
const newConfigs = r.configs;
newConfigs.push({ name, url, query });
return userRef.update({
configs: newConfigs
})
}).then((r) => {
console.log('updated state: ', r);
})
But unfortunately I am getting this error:
Uncaught (in promise) Error: Invalid JSON payload received. Unknown name "currentDocument" at 'document': Cannot find field.
at handleApiResponse (mod.js:8)
at async Reference.update (Reference.js:112)
Is there a better workflow for this series of steps?
Issue-Label Bot is automatically applying the label bug
to this issue, with a confidence of 0.76. Please mark this comment with
Links: app homepage, dashboard and code for this bot.
This error was fixed on the beta of version 1.0.0, but I'll push a quick fix for the current versions too.
Published a quick fix in version v0.7.2, please make sure you use the latest version before checking again.
Let me know if the issue resolved, and thank you very much for opening the issue!
@samuelgozi Still getting an error, but a different one:
Uncaught (in promise) Error: Invalid JSON payload received. Unknown name "fieldPaths": Cannot bind query parameter. Field 'fieldPaths' could not be found in request message.
at handleApiResponse (mod.js:8)
at async Reference.update (Reference.js:115)
So sorry. I usually test on a live server multiple times in addition to regular tests and consulting the reference. The previous time I didn't have much time so I skipped the live tests and fixed it from memory., and that's why I missed the error(it was misspelling)...
It's now fixed(really). You will see the changes in version v0.7.3.
Please let me know If you see any issue again(You really shouldn't). And Thank you very much!
Seems to be working now! thanks a bunch