![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Mongodb
ezreal_pan
这个作者很懒,什么都没留下…
展开
-
mongodb 批量把date类型数据改为时间戳
db.customer_poster.find().forEach( function(res){ print("poster_id:",res.poster_id); if (res.update_time instanceof Date){ var updateTime=res.update_time.getTime(); updateTime=updateTime/1000; updateT.原创 2021-09-02 14:59:34 · 680 阅读 · 0 评论 -
mongodb replaces the value of a field with the specified value($set)
官方文档:https://docs.mongodb.com/manual/reference/operator/update/set/利用$set操作符进行全量替换:数据库中的数据:{ "_id": { "$oid": "607f8fb2f1cf542ae93e0fd6" }, "cal_id": { "$numberLong": "2" }, "attach": { "goods": {原创 2021-05-20 17:56:55 · 100 阅读 · 0 评论 -
golang mongodb 涉及到多字段排序
涉及到多字段排序的操作,代码结构如下,详情见注释:func makeGoodsOptions(page, pageSize int64) *options.FindOptions { //分页 limit := pageSize skip := (page - 1) * pageSize //排序 map无序,因此这样子会报错 // sortMap := make(map[string]interface{}, 0) // sortMap["update_time"] = -1 //原创 2021-04-23 16:47:31 · 3530 阅读 · 2 评论 -
multi-key map passed in for ordered parameter sort
记录一次阅读源码的过程。在使用golang mongo 查询的过程中,使用了sort进行排序,使用了多个字段进行排序。结果,返回multi-key map passed in for ordered parameter sort 这个错误。首先上网查了一下这个错误,发现没有人遇到过这样的问题。查询中,使用了find方法,以及排序,如下图所示。我看了一下源码。在源码中找到Find()方法。定位到Find()方法中,sort参数解析。从源码看,的确是不支持多个原创 2021-04-23 14:39:53 · 2301 阅读 · 2 评论 -
mongodb query array count
数据库中数据结构:{ "_id": { "$oid": "607f8fb2f1cf542ae93e0fd6" }, "cal_id": { "$numberLong": "2" }, "attach": { "goods": { "list": [{ "id": { "$numberLong": "257"原创 2021-04-21 17:05:28 · 244 阅读 · 0 评论 -
mongodb delete document Match on Nested Fields ($pull)
数据库中数据结构:{ "_id": { "$oid": "607f8fb2f1cf542ae93e0fd6" }, "cal_id": { "$numberLong": "2" }, "attach": { "goods": { "list": [{ "id": { "$numberLong": "257"原创 2021-04-21 10:46:15 · 125 阅读 · 0 评论