【问题标题】:Cloud Functions ERROR: cannot convert an array value in an array value [closed]云函数错误:无法将数组值转换为数组值[关闭]
【发布时间】:2019-07-14 02:25:57
【问题描述】:

我正在尝试使用 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)

【问题讨论】:

标签: firebase google-cloud-firestore google-cloud-functions


【解决方案1】:

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

您需要更改数据以使其看起来更像:

[
  {"id": "-LXRXPFgA6sC9Mg0GQMt","number":1,"label":"Sushi premium"},
  // ...
]

【讨论】:

    猜你喜欢
    • 2019-01-15
    • 2020-10-05
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 1970-01-01
    相关资源
    最近更新 更多