Fix the wrong key about FindOne in mongo of goctl. (#2523)

master
wuleiming2009 2 years ago committed by GitHub
parent 05a5de7c6d
commit ea52fe2e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -105,7 +105,7 @@ func (m *defaultUserModel) FindOne(ctx context.Context, id string) (*User, error
}
var data User
key := prefixUserCacheKey + data.ID.Hex()
key := prefixUserCacheKey + id
err = m.conn.FindOne(ctx, key, &data, bson.M{"_id": oid})
switch err {
case nil:

@ -47,7 +47,7 @@ func (m *default{{.Type}}Model) FindOne(ctx context.Context, id string) (*{{.Typ
}
var data {{.Type}}
{{if .Cache}}key := prefix{{.Type}}CacheKey + data.ID.Hex(){{end}}
{{if .Cache}}key := prefix{{.Type}}CacheKey + id{{end}}
err = m.conn.FindOne(ctx, {{if .Cache}}key, {{end}}&data, bson.M{"_id": oid})
switch err {
case nil:

Loading…
Cancel
Save