mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 01:30:25 +08:00
Fix the wrong key about FindOne in mongo of goctl. (#2523)
This commit is contained in:
parent
05a5de7c6d
commit
ea52fe2e0d
@ -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…
Reference in New Issue
Block a user