Nested arrays are not supported

New Firebase Firestore Database Announces

The function DocumentReference.set () was called with invalid data. Nested arrays are not supported.

When trying to save the following object:

{ "desc" : "Blala", "geojson" : { "features" : [ { "geometry" : { "coordinates" : [ 8.177433013916017, 48.27753810094064 ], "type" : "Point" }, "type" : "Feature" } ], "type" : "FeatureCollection" }, "location" : { "lat" : 48.27753810094064, "lng" : 8.177433013916017 }, "name" : "Wald und Wiesen", "owner" : "8a2QQeTG2zRawZJA3tr1oyOAOSF3", "prices" : { "game" : { "Damwild" : 10, "Raubwild" : 300, "Rehwild" : 250, "Schwarzwild" : 40 }, "perDay" : 35 }, "rules" : "Keine Regeln!", "wild" : { "desc" : "kein Wild", "tags" : [ "Damwild", "Rehwild", "Schwarzwild", "Raubwild" ] } } 

what exactly is a nested array that firestore complains about? I can not find it in the documentation.

If this is a GeoJSON object - how would I save it?

+11
firebase google-cloud-firestore
source share
3 answers

UPDATE: this has been fixed in Firebase JS SDK 4.6.0. Directly nested arrays are still not supported, but now you can have an array containing an object that contains an array, etc.

This is a bug in the currently released SDK.

The backend has the limitation that only directly nested arrays are not supported.

In your case, you have arrays containing objects containing arrays, and the validation logic in clients prohibits this when it should not.

There is no public error tracking this, but I will send it back when we have a fix.

+8
source share

You can adapt the serialization function, which converts arrays with types of objects into a map. The keys can be numeric to maintain order.

i.e. { 1: Object, 2: Object2 ... }

When deserializing, you can return Object.values(data); back to the array to be used on the client side.

+4
source share

I can not comment, so here: this is fixed in 4.6.0, see the release notes: https://firebase.google.com/support/release-notes/js#4.6.0

Cloud Firestore

FIXED Fixed checking of nested arrays to ensure indirect nesting.

+2
source share

All Articles