【发布时间】:2020-06-17 20:48:24
【问题描述】:
如果我这样存储当前时间:
type Test struct {
Id string `bson:"id" json:"id,omitempty"`
TestTime time.Time `bson:"testTime" json:"testTime,omitempty"`
}
...
t := Test {
Id : "TEST0001",
TestTime : time.Now(),
}
...
c.Insert(t)
然后我使用 mongochef 搜索它:
{
"_id" : ObjectId("576bc7a48114a14b47920d60"),
"id" : "TEST0001",
"testTime" : ISODate("2016-06-23T11:27:30.447+0000")
}
那么,mgo 默认存储 ISODate,如何存储 Date 而不是 ISODate 呢?
【问题讨论】: