Reputation: 335
I'm trying to add merge:true
option to my .set()
write following the docs and I can't figure out why my syntax is invalid since I'm copying the docs..
My error
index.cjs.js:1751 Uncaught Error: Reference.set failed: second argument must be a valid function.
My code
firebase.database().ref('react').set({
data
}, {merge: true});
Trying to emulate this snippet from the docs
var cityRef = db.collection('cities').doc('BJ');
var setWithMerge = cityRef.set({
capital: true
}, { merge: true });
Ultimate goal being to push to the database without overwriting.
Upvotes: 0
Views: 420
Reputation: 317760
The snippet you're looking at from the documentation is for Cloud Firestore. The code you're attempting to write is accessing Realtime Database. They are not the same product, and their SDKs have different APIs. Be sure that you're looking at the documentation for the product that you actually want to work with.
Upvotes: 1