j809809jkdljfja
j809809jkdljfja

Reputation: 807

Angularfire2 and updating different objects using data fan-out

I need to update objects in my database, so I do this:

const items = af.database.list('/items');
items.update('key-of-some-data1', { size: newSize1 });
items.update('key-of-some-data2', { size: newSize2 });

This works like a charm, but I would like to update items with a "data fan-out" as described here: https://firebase.google.com/docs/database/web/read-and-write https://firebase.googleblog.com/2015/10/client-side-fan-out-for-data-consistency_73.html

So I do:

var updates = {};
updates['key-od-some-data1']= { size: newSize1 };
updates['key-od-some-data2']= { size: newSize2 };
items.update(updates);

Unfortunately I get this error:

zone.js:140 Uncaught Error: Error in ./AppComponent class AppComponent - inline template:30:2 caused by: Method requires a key, snapshot, reference, or unwrapped snapshot. Got: object

Is it even possible to update with data fan-out to the database with angularfire2? Does data fan-out work only with the same object key or something?

Upvotes: 2

Views: 920

Answers (1)

Sasxa
Sasxa

Reputation: 41314

Replace:

const items = af.database.list('/items');

with:

const items = af.database.object('/items');

Upvotes: 4

Related Questions