personal-website/webfilesystem/directory.go

37 lines
758 B
Go
Raw Normal View History

2023-05-05 14:44:03 +00:00
package webfilesystem
import (
"github.com/mitchellh/mapstructure"
"go.mongodb.org/mongo-driver/bson/primitive"
)
type DirectoryData struct {
Parent primitive.ObjectID `bson:"parent"`
Children []primitive.ObjectID `bson:"children"`
}
// type Directory struct {
// Header Header `bson:"header"`
// Data DirectoryData `bson:"data"`
// }
// func (d *Directory) Get() interface{} {
// return d
// }
func castToFile(raw *interface{}) *WebFSFile {
var dirPtr interface{} = *raw
return dirPtr.(*WebFSFile)
}
func castToDirectory(data interface{}) (*FolderData, error) {
dirData := FolderData{}
err := mapstructure.Decode(data.(primitive.D).Map(), &dirData)
if err != nil {
return nil, err
}
return &dirData, nil
}
// func List()