Home
Sign Up
Sign In
The Go Programming Language
›
http://golang.org/
›
Go Playground
Go Projects
›
Revel Web Framework
Advertisement
V2EX
›
Go 编程语言
mgo 条件修改 mongodb
harry890829
·
Jul 7, 2017
· 1819 views
This topic created in 3427 days ago, the information mentioned may be changed or developed.
在使用 mgo 修改数据库中谋个字段可以直接使用$set
现在遇到一个情况,比如我想当 a 的值为 1 时,才更改 a 的值,是不是一定要走一遍查询拿出来后,再使用$set 把值改变么?
mgo
set
MongoDB
修改
3 replies
•
2017-07-07 18:14:32 +08:00
cxbig
Jul 7, 2017
1
https://docs.mongodb.com/manual/reference/method/db.collection.update/
JackeyGao
Jul 7, 2017
2
https://gist.github.com/border/3489566#file-mgoexample-go-L82
harry890829
OP
Jul 7, 2017
3
@
cxbig
#1
@
JackeyGao
#2
脑子有点秀逗了,发完后我想了想,问题有点蠢……我前两天还自己还用过这个功能
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
971 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 33ms ·
UTC 20:15
·
PVG 04:15
·
LAX 12:15
·
JFK 15:15
♥ Do have faith in what you're doing.
❯