diff --git a/tools/goctl/model/mongo/template/model.tpl b/tools/goctl/model/mongo/template/model.tpl index c88f1462..c07d7896 100644 --- a/tools/goctl/model/mongo/template/model.tpl +++ b/tools/goctl/model/mongo/template/model.tpl @@ -29,7 +29,7 @@ func newDefault{{.Type}}Model(conn {{if .Cache}}*monc.Model{{else}}*mon.Model{{e func (m *default{{.Type}}Model) Insert(ctx context.Context, data *{{.Type}}) error { - if !data.ID.IsZero() { + if data.ID.IsZero() { data.ID = primitive.NewObjectID() data.CreateAt = time.Now() data.UpdateAt = time.Now()