aboutsummaryrefslogtreecommitdiff
path: root/db/mongo.go
diff options
context:
space:
mode:
Diffstat (limited to 'db/mongo.go')
-rw-r--r--db/mongo.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/db/mongo.go b/db/mongo.go
index c3e31dd..1c694e7 100644
--- a/db/mongo.go
+++ b/db/mongo.go
@@ -6,6 +6,7 @@ import (
"net"
"github.com/globalsign/mgo"
+ "github.com/globalsign/mgo/bson"
log "github.com/sirupsen/logrus"
)
@@ -39,5 +40,14 @@ func initSessions(user, pass, ip string) {
}
func insert(new Paste) error {
+ log.Infof("new paste struct: %+v", new)
return pastes.Insert(new)
}
+
+func fetch(hash string) (Paste, error) {
+ p := Paste{}
+
+ q := bson.M{"hash": hash}
+ err := pastes.Find(q).One(&p)
+ return p, err
+}