GraphQL API and utilities for the rpdata project
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

  1. package changes
  2. import (
  3. "git.aiterp.net/rpdata/api/internal/store"
  4. "git.aiterp.net/rpdata/api/models"
  5. "github.com/globalsign/mgo"
  6. "github.com/globalsign/mgo/bson"
  7. "sync"
  8. )
  9. var collection *mgo.Collection
  10. var submitMutex sync.Mutex
  11. func list(query bson.M, limit int) ([]models.Change, error) {
  12. changes := make([]models.Change, 0, 64)
  13. err := collection.Find(query).Limit(limit).Sort("-date").All(&changes)
  14. return changes, err
  15. }
  16. func init() {
  17. store.HandleInit(func(db *mgo.Database) {
  18. collection = db.C("common.changes")
  19. })
  20. }