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

Golang / mgo-设置“ $ set”为更新条件

update := bson.M{"$push": bson.M{"versions" : Versions{"x", 123}}}

if nctime, _ := time.Parse("2006-01-02 15:04:05", ctime); group.LastUpdate.Before(nctime) {
    // update.$set = bson.M{"lastupdate": nctime}
}

_ = db.Mongo.C("collection").UpdateId(group.Id, update)

How can I add the $set part to an existing bson.M? There must be a way to do it, but I couldn't find it.

  update["$set"] = bson.M{"lastupdate": nctime}

近期文章

  • 多个响应。Go中的WriteHeader调用
  • 如何通过Gmail API发送电子邮件? 走
  • 转到:内置的功能-容量是否有所不同
  • 您如何使用go-simplejson遍历json文件
  • 通过反射嵌套参考结构
  • 使用空字段创建结构的一线工具?
  • Go使用哪个IDE? [关闭]
  • 在Windows中编译Go文件?
  • 在golang示例中运行测试时“不允许导入周期”
  • 如何在Golang中使用javascript获取特定的网站元素或提交表单
  • Golang频道维护
  • 如何验证JWT签名?
  • 为什么binary.Size()返回(-1)?
  • 将字符串类型转换为int
  • Go探查器的输出令人困惑(且不正确?)
  • 部署Google App Engine“ Cloud Datastore Service”错误
  • 我在森林的POST请求中应该使用哪种类型?
  • 如何在Go中将动态创建的结构作为非指针对象传递
  • Golang执行:状态:文件移至该目录后没有此类文件或目录
  • 浮点数的字节顺序

Copyright ©2022 我爱占星 All Rights Reserved.

浙ICP备2022030071号-1

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

友情链接:代码精华