问题
I am trying to pass in this data into a field of a document using Cloud Functions:
[ [ '-LXRXPFgA6sC9Mg0GQMt', 1, 'Sushi premium' ], [ '-LXRSAp3jpB8EUbZU-0c', 1, 'Caramel Glazed Donuts' ] ]
The error I got is:
Error: 3 INVALID_ARGUMENT: Cannot convert an array value in an array value. at Object.exports.createStatusError (/user_code/node_modules/firebase-admin/node_modules/grpc/src/common.js:91:15) at Object.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:1204:28) at InterceptingListener._callNext (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:568:42) at InterceptingListener.onReceiveStatus (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:618:8) at callback (/user_code/node_modules/firebase-admin/node_modules/grpc/src/client_interceptors.js:845:24)
What I expected: I expected it to be valid. Why is this invalid? Did i do something wrong?
回答1:
Nested arrays are not supported in Cloud Firestore. You can store arrays of objects, and those objects can have fields that are arrays, but multi-level arrays are not possible.
You would need to change your data to look something more like:
[
{"id": "-LXRXPFgA6sC9Mg0GQMt","number":1,"label":"Sushi premium"},
// ...
]
来源:https://stackoverflow.com/questions/54785637/cloud-functions-error-cannot-convert-an-array-value-in-an-array-value