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

This commit is contained in:
wuleiming2009 2022-10-17 19:58:57 +08:00 committed by GitHub
parent 05a5de7c6d
commit ea52fe2e0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -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:

View File

@ -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: