我爱占星网 我爱占星网
首页
编程
java
php
前端
首页 编程 java php 前端

无法将新对象添加到文档

I am trying to add a new field productFiles(along with its field) to an existing document in MongoDb. But I am getting follwing error:

"the positional operator did not find the match needed from the query."

query := bson.M{
     "productId": productId,
}

update := bson.M{
    "$set": bson.M{ 
        "productFiles.$.updatedOn": int32(time.Now().Unix()),
        "productFiles.$.updatedBy": userId,
    },
}

err := repo.Collection().Update(query, update)

近期文章

  • 如何列出远程服务器中的文件
  • 如何在Golang中计算嵌套/迭代的MD5哈希?
  • 使用docker golang库的卷挂载选项'z'
  • Golang cmd.Start()有时挂在保险丝安装的目录上
  • 正确设置httputil.ReverseProxy Foward响应流
  • DynamoDB使用AWS GoLang SDK列出所有备份
  • 如何从golang可执行文件中获取当前的gcloud用户名?
  • 在Go中使用Boost进程间机制(托管共享内存,条件变量…)
  • 从Consul获得的具有持久连接的gRPC服务的客户端注册表
  • Goroutines一会儿不回复
  • 为什么goroutine暂停了几分钟
  • 在Firestore中更新值时没有字段错误
  • sqlx将postgres数组扫描到结构中
  • 关系不存在(golang / mac OS)
  • 使用libc而不是glibc的Golang c-archive
  • 带有串行通信的io.Reader中缺少字节
  • 如何将mongodb会话放入creachadair / jrpc2处理程序中
  • 在html模板中找不到自定义模板功能[重复]
  • 阅读缓存DIY图书时出现Go映射线程安全问题
  • 在Firestore中忽略Nil值的最佳做法

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

部分图文来自网络,如有侵犯您的版权,请告诉我们删除

友情链接:代码精华