diff --git a/sys/db/dbconn.go b/sys/db/dbconn.go index 4bd5ec27a..7cf6cd1df 100644 --- a/sys/db/dbconn.go +++ b/sys/db/dbconn.go @@ -582,12 +582,15 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er c *mongo.Cursor keys map[string]string tempdata map[string]string + isfound bool ) keys = make(map[string]string) if err = this.Redis.HGetAll(this.ukeylist(uid, id), data); err != nil && err != lgredis.RedisNil { return } + isfound = true if err == lgredis.RedisNil { + isfound = false if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{"uid": uid}); err != nil { return err } else { @@ -611,6 +614,7 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er if tempdata, err = json.MarshalMap(data); err != nil { return } + isfound = true } key := this.ukeylist(uid, _id) pipe.HMSetForMap(key, tempdata) @@ -622,7 +626,10 @@ func (this *DBModel) GetListObj(uid string, id string, data interface{}) (err er } } } - + if !isfound { + err = fmt.Errorf("no found data table:%s uid:%s id:%s", this.TableName, uid, id) + return + } if this.Expired > 0 { childs := make(map[string]struct{}, len(keys)) for _, v := range keys {