You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
540 B
25 lines
540 B
package changes
|
|
|
|
import (
|
|
"git.aiterp.net/rpdata/api/internal/store"
|
|
"git.aiterp.net/rpdata/api/models"
|
|
"github.com/globalsign/mgo"
|
|
"github.com/globalsign/mgo/bson"
|
|
"sync"
|
|
)
|
|
|
|
var collection *mgo.Collection
|
|
var submitMutex sync.Mutex
|
|
|
|
func list(query bson.M, limit int) ([]models.Change, error) {
|
|
changes := make([]models.Change, 0, 64)
|
|
err := collection.Find(query).Limit(limit).Sort("-date").All(&changes)
|
|
|
|
return changes, err
|
|
}
|
|
|
|
func init() {
|
|
store.HandleInit(func(db *mgo.Database) {
|
|
collection = db.C("common.changes")
|
|
})
|
|
}
|