Cloud Functions 错误:无法将数组值转换为数组值 [英] Cloud Functions ERROR: cannot convert an array value in an array value

查看:17
本文介绍了Cloud Functions 错误:无法将数组值转换为数组值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Cloud Functions 将以下二维数据数组传递到文档的字段中.

I am trying to pass in the following 2d array of data into a field of a document using Cloud Functions.

[ [ '-LXRXPFgA6sC9Mg0GQMt', 1, 'Sushi premium' ], [ '-LXRSAp3jpB8EUbZU-0c', 1, 'Caramel Glazed Donuts' ] ]

我得到的错误是:

>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)

推荐答案

Cloud Firestore 不支持嵌套数组.你可以存储对象的数组,这些对象可以有数组的字段,但多级数组是不可能的.

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"},
  // ...
]

这篇关于Cloud Functions 错误:无法将数组值转换为数组值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆