This commit is contained in:
@@ -37,7 +37,7 @@ func NextMany(category, name string, increment int) (int, error) {
|
|||||||
doc := counter{}
|
doc := counter{}
|
||||||
|
|
||||||
_, err := collection.Find(bson.M{"_id": id}).Apply(mgo.Change{
|
_, 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,
|
Upsert: true,
|
||||||
ReturnNew: true,
|
ReturnNew: true,
|
||||||
}, &doc)
|
}, &doc)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package posts
|
package posts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"git.aiterp.net/rpdata/api/internal/counter"
|
||||||
"git.aiterp.net/rpdata/api/models"
|
"git.aiterp.net/rpdata/api/models"
|
||||||
"github.com/globalsign/mgo/bson"
|
"github.com/globalsign/mgo/bson"
|
||||||
)
|
)
|
||||||
@@ -20,6 +21,8 @@ func Remove(post models.Post) (models.Post, error) {
|
|||||||
return models.Post{}, err
|
return models.Post{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
counter.NextMany("next_post_id", post.LogID, -1)
|
||||||
|
|
||||||
return post, nil
|
return post, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user