|
@@ -108,7 +108,10 @@ func SortPrev(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
Query: repo.Map{"_id": id},
|
|
|
})
|
|
|
currentSort := result["sort"].(int32)
|
|
|
- currentType := result["type"].(string)
|
|
|
+ currentType := ""
|
|
|
+ if v, ok := result["type"]; ok {
|
|
|
+ currentType = v.(string)
|
|
|
+ }
|
|
|
query := repo.Map{"sort": repo.Map{"$gt": int(currentSort)}}
|
|
|
if len(currentType) > 0 {
|
|
|
query["type"] = currentType
|
|
@@ -160,8 +163,11 @@ func SortNext(c *gin.Context, apictx *ApiSession) (interface{}, error) {
|
|
|
Query: repo.Map{"_id": id},
|
|
|
})
|
|
|
currentSort := result["sort"].(int32)
|
|
|
- currentType := result["type"].(string)
|
|
|
- query := repo.Map{"sort": repo.Map{"$gt": int(currentSort)}}
|
|
|
+ currentType := ""
|
|
|
+ if v, ok := result["type"]; ok {
|
|
|
+ currentType = v.(string)
|
|
|
+ }
|
|
|
+ query := repo.Map{"sort": repo.Map{"$lt": int(currentSort)}}
|
|
|
if len(currentType) > 0 {
|
|
|
query["type"] = currentType
|
|
|
}
|