You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
firebase.firestore().collection('...').withConverter(converter).add(data) invokes converter.toFirestore twice while firebase.firestore().collection('...').withConverter(converter).doc().set(data) invokes converter.toFirestore only once.
Is this intended behavior?
Although this is not a desirable style of processing, if the toFirestore() process has a side effect on the input value, the second invocation fails (See example below).
Steps to reproduce:
try to run following code please.
Relevant Code:
const firebase = require('firebase')
// Please use your firebase config here
firebase.initializeApp(firebaseConfig)
const document = {
someArray: [
{ text: '' },
],
}
const converter = {
toFirestore: (modelObject) => {
console.log('toFirestore', modelObject)
modelObject.someArray = 'text'
return { text: modelObject.someArray[0].text }
},
fromFirestore: () => {
throw new ReferenceError()
},
}
// log 'toFirestore' twice, and then fail second conversion.
firebase.firestore().collection('posts')
.withConverter(converter)
.add(document)
// log 'toFirestore' only once and complete as expected.
firebase.firestore().collection('posts')
.withConverter(converter)
.doc()
.set(document)
The text was updated successfully, but these errors were encountered:
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
firebase.firestore().collection('...').withConverter(converter).add(data)
invokesconverter.toFirestore
twice whilefirebase.firestore().collection('...').withConverter(converter).doc().set(data)
invokesconverter.toFirestore
only once.Is this intended behavior?
Although this is not a desirable style of processing, if the toFirestore() process has a side effect on the input value, the second invocation fails (See example below).
Steps to reproduce:
try to run following code please.
Relevant Code:
The text was updated successfully, but these errors were encountered: