adding basic data storage
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"crowsnest-frontend/internal/model"
|
||||
"crowsnest-frontend/internal/data"
|
||||
)
|
||||
|
||||
func test(w http.ResponseWriter, req *http.Request) {
|
||||
@@ -14,6 +15,11 @@ func test(w http.ResponseWriter, req *http.Request) {
|
||||
}
|
||||
}
|
||||
|
||||
func PrintAllKeys(ds data.IDatastore) {
|
||||
m, err := ds.GetAllKeys()
|
||||
fmt.Println(m, err)
|
||||
}
|
||||
|
||||
func main() {
|
||||
http.HandleFunc("/test", test)
|
||||
|
||||
@@ -24,7 +30,10 @@ func main() {
|
||||
|
||||
a := &model.Article{}
|
||||
|
||||
fmt.Println(a.Hash())
|
||||
fds, _ := data.NewFileDatastore("data.json")
|
||||
fmt.Println(fds.jetAll())
|
||||
repo := data.NewDefaultRepository[*model.Article](fds, "article")
|
||||
fmt.Println(repo.Create(a))
|
||||
|
||||
//http.ListenAndServe(":8090", nil)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user