aboutsummaryrefslogtreecommitdiff
path: root/db/db.go
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2020-05-09 14:28:24 -0700
committerjackyzha0 <[email protected]>2020-05-09 14:28:24 -0700
commit35ce1bff3496c67cda124aea3c36bc5b66b1e4e6 (patch)
tree6dedc5d47077ff9831f2e944bc83dd957eb3f894 /db/db.go
parentMerge pull request #1 from jackyzha0/hash (diff)
downloadctrl-v-35ce1bff3496c67cda124aea3c36bc5b66b1e4e6.tar.xz
ctrl-v-35ce1bff3496c67cda124aea3c36bc5b66b1e4e6.zip
working mongo doc add
Diffstat (limited to 'db/db.go')
-rw-r--r--db/db.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/db/db.go b/db/db.go
index 5c35495..a6f439e 100644
--- a/db/db.go
+++ b/db/db.go
@@ -3,6 +3,7 @@ package db
import (
"os"
+ "github.com/jackyzha0/ctrl-v/hashing"
"github.com/joho/godotenv"
log "github.com/sirupsen/logrus"
)
@@ -21,8 +22,10 @@ func init() {
initSessions(mUser, mPass, mIP)
}
-// creates a new
-func New(hash, content string) error {
+// creates a new paste with content and hash
+func New(ip, content string) error {
+ // generate hash from ip
+ hash := hashing.GenerateURI(ip)
// create new struct
new := Paste{
@@ -35,3 +38,8 @@ func New(hash, content string) error {
insertErr := insert(new)
return insertErr
}
+
+// lookup
+func Lookup(hash string) (Paste, error) {
+ return fetch(hash)
+}