textualize/storage/Local/DocumentDriver.go
Yehoshua Sandler c49f8e4d07
refact: generalized back end structs (#1)
* refact: generalized back end structs

* refact: fixed front end type, removed dead code

* removed test image folder

* refact: removed dead structs
2023-05-26 19:23:35 -05:00

23 lines
729 B
Go

package storage
import (
"encoding/json"
"textualize/entities"
)
func (d LocalDriver) WriteDocumentCollection(documentCollection entities.DocumentCollection, projectName string) bool {
jsonData, _ := json.MarshalIndent(documentCollection, "", " ")
writeError := WriteDataToAppDir(jsonData, "/projects/"+projectName+"/", "Documents.json")
return writeError == nil
}
func (d LocalDriver) ReadDocumentCollection(projectName string) entities.DocumentCollection {
documentCollectionData := entities.DocumentCollection{}
readError := AssignFileDataToStruct("/projects/"+projectName+"/Documents.json", &documentCollectionData)
if readError != nil {
return entities.DocumentCollection{}
}
return documentCollectionData
}