Is there (or was it accepted) something like "merging" or "batch" mode in Firebase?

While doing some more programming with Firebase today, I found that I wanted several features:

1) Combine :

Say I have a firebase refthat has a value {a:1,b:2,c:3}.

If I do something like ref.set({a:-1,b:-2}), the new value will be (not surprisingly) be {a:-1,b:-2}.

Instead, imagine ref.mergeSet({a:-1,b:-2})which will cause the ref value to be {a:-1,b:-2,c:3}.

Now I understand that to achieve this result, I could do something like ref.child("a").set(-1)and ref.child("b").set(-2), but at least in some cases I would prefer to get only one call for my handler .on().

This goes into my second idea.

2) Package :

In my application, I need a way to force an arbitrary number of calls to .setcause only one call .onin other clients. Sort of:

ref.startBatch()
ref.child("a").set(1)
ref.child("b").set(2)
....
ref.endBatch()

In batch mode, .setit will not result in a call .on; instead, the minimum number of calls .onwill be caused by the call .endBatch.


I readily admit that these ideas are quite nascent, and I won’t be surprised if they contradict the existing architectural features of Firebase, but I thought I would share them. I found that I had to spend more time maintaining consistency between clients when using Firebase than I expected.

Thanks again and keep up the great work.

+5
source share
1

: update() - Firebase PATCH REST API, , . , "mergeSet" :

ref.update({a: -1, b: -2});

'a' 'b', 'c' .


OLD ANSWER

! , . , support@firebase.com, .

, , , /, . , , Firebase , (, ..) , , , . , , set(), , Firebase.

, , . , , "a" "b" , "ab" ref.child('ab').set({a:-1, b:-2});, c.

, . -, , API ! support@firebase.com: -)

+6

All Articles