preserve ObjectID on insert
This commit is contained in:
parent
91ef568a64
commit
64a4178975
@ -41,8 +41,10 @@ func GetCollectionName(m ModelInterface) string {
|
|||||||
|
|
||||||
// PrepareInsert creates new bson id and insert time
|
// PrepareInsert creates new bson id and insert time
|
||||||
func (m *Model) PrepareInsert() {
|
func (m *Model) PrepareInsert() {
|
||||||
id := bson.NewObjectId()
|
if m.ID == nil {
|
||||||
m.ID = &id
|
id := bson.NewObjectId()
|
||||||
|
m.ID = &id
|
||||||
|
}
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
m.InsertTime = &now
|
m.InsertTime = &now
|
||||||
m.UpdateTime = &now
|
m.UpdateTime = &now
|
||||||
|
Loading…
x
Reference in New Issue
Block a user