fix article list error

This commit is contained in:
deepzz0
2016-12-08 23:15:40 +08:00
parent adbe1b97f4
commit 01335ea06c
5 changed files with 25 additions and 20 deletions

13
db.go
View File

@@ -73,7 +73,17 @@ func init() {
ms.Close()
ms, c = db.Connect(DB, COLLECTION_ARTICLE)
index = mgo.Index{
Key: []string{"id", "slug"},
Key: []string{"id"},
Unique: true,
DropDups: true,
Background: true,
Sparse: true,
}
if err := c.EnsureIndex(index); err != nil {
logd.Fatal(err)
}
index = mgo.Index{
Key: []string{"slug"},
Unique: true,
DropDups: true,
Background: true,
@@ -461,6 +471,7 @@ func AddToLinkedList(id int32) {
artc.Prev = Ei.Articles[i-1]
if Ei.Articles[i-1].Next != nil {
artc.Next = Ei.Articles[i-1].Next
Ei.Articles[i-1].Next.Prev = artc
}
Ei.Articles[i-1].Next = artc
}