Nested arrays are not supported

Can't comment so here it goes: this is fixed in 4.6.0, see release notes: https://firebase.google.com/support/release-notes/js#4.6.0

Cloud Firestore

FIXED Fixed the validation of nested arrays to allow indirect nesting.


UPDATE: This was fixed in Firebase JS SDK 4.6.0. Directly nested arrays are still unsupported, but you can now have an array that contains an object that contains an array, etc.

This is a bug in the currently released SDKs.

The backend has the restriction that only directly nested Arrays are unsupported.

In your case you have arrays containing objects containing arrays and the validation logic in the clients is disallowing it when it shouldn't.

There's no public bug tracking this but I'll post back when we have a fix.


You could adapt a serialization function that converts arrays with object types into a map. The keys can be numeric to maintain order.

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

On deserialization you can get the Object.values(data); to put it back into an array to be used client-side.


Python:

# Matrix storage in firestore

def matrix_to_fb_data(matrix):
    return [{'0': row} for row in matrix]

def fb_data_to_matrix(fb_data):
    return [row['0'] for row in fb_data]

Firestore doesn't allow 2d arrays, like previous answers have noted, but they allow arrays of maps... of arrays :)