Cloud Functions ERROR: cannot convert an array value in an array value [closed]

て烟熏妆下的殇ゞ 提交于 2020-06-25 07:58:12

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!