adding basic data storage

This commit is contained in:
2024-12-27 22:34:43 +01:00
parent ab1b709c77
commit aeb9de71a1
9 changed files with 259 additions and 15 deletions

View File

@@ -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)
}