node.js - How to push values in existing array on firestore in nodeJs?
问题描述
I have this token schema over the firestore contains id and array of tokens
{ userId: "some String", "tokens": [ "token1", "token2" ] }
I need to push new tokens in tokens array where an Id matches with this schema userId
I am using this below code but not able to push values
docRef.get().then(async function (doc) {
if (!doc.empty) {
let here1 = await db.collection("tokens").doc(doc.id);
let here = doc.docs.update({
deviceTokens: admin.firestore.FieldValue.arrayUnion(body.deviceToken)
})
}})
can someone explain what's the error here?
解决方案
推荐阅读
- c# - 我不明白为什么在基类中测试可能的接口是错误的
- c# - 安装 Microsoft.Azure.SignalR.AspNet 会在部署到服务器时导致方法未实现运行时错误,但在 Visual Studio 2017 上运行良好
- reactjs - Redux 改变多种状态
- java - ListView 适配器异步操作
- python-3.x - 如何在 NEAT(增强拓扑的神经进化)中设置层数?
- ionic4 - Ionic 4 构建后未在平台中创建“ios”文件夹
- fortran - 在 Fortran 中编写混合的 ascii 和二进制数据
- events - 如何在 Modelica 中使用布尔开关来防止库存低于零?
- hanami - 如何使用 Hanami::Repository 在更新/删除命令中使用条件?
- android - 如何在不登录的情况下保存用户值,然后在其他活动的当前用户值中添加数据字段?