更新最新数据.

This commit is contained in:
eson 2020-12-09 10:41:55 +08:00
parent 5f7d92a781
commit 3d00fca1db

View File

@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/json"
"log"
"time"
_ "github.com/go-sql-driver/mysql"
@ -30,7 +31,11 @@ func main() {
cla := engine.Table("count_live_anchors")
cur, err := mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{})
start, err := time.ParseInLocation("2006-01-02 15:04:03", "2020-11-30 16:29:17", time.Local)
if err != nil {
panic(err)
}
cur, err := mdb.C.CountLiveAnchors.Find(context.TODO(), bson.M{"create_at": bson.M{"$gte": start}})
if err != nil {
panic(err)
}
@ -52,7 +57,7 @@ func main() {
c.CountMap = string(data)
_, err = cla.Insert(c)
if err != nil {
panic(err)
log.Println(err)
}
}
}