posts, counter: Fixed post positions issues when a post is deleted.
the build was successful

This commit is contained in:
2018-12-02 21:27:50 +01:00
parent 31239330df
commit ac2b79e88a
2 changed files with 4 additions and 1 deletions
+1 -1
View File
@@ -37,7 +37,7 @@ func NextMany(category, name string, increment int) (int, error) {
doc := counter{}
_, err := collection.Find(bson.M{"_id": id}).Apply(mgo.Change{
Update: bson.M{"$inc": bson.M{"value": 1}},
Update: bson.M{"$inc": bson.M{"value": increment}},
Upsert: true,
ReturnNew: true,
}, &doc)
+3
View File
@@ -1,6 +1,7 @@
package posts
import (
"git.aiterp.net/rpdata/api/internal/counter"
"git.aiterp.net/rpdata/api/models"
"github.com/globalsign/mgo/bson"
)
@@ -20,6 +21,8 @@ func Remove(post models.Post) (models.Post, error) {
return models.Post{}, err
}
counter.NextMany("next_post_id", post.LogID, -1)
return post, nil
}