Update storage to new object format

This commit is contained in:
Bel LaPointe
2020-07-22 20:11:52 -06:00
parent 3b174e3d60
commit 4d667e7b11
11 changed files with 232 additions and 62 deletions

34
storage/entity/one.go Normal file
View File

@@ -0,0 +1,34 @@
package entity
const (
Name = "_id"
Relationship = "relationship"
Type = "type"
Title = "title"
Image = "image"
Text = "text"
Modified = "modified"
Connections = "connections"
)
type One struct {
Name string `bson:"_id,omitempty"`
Type string `bson:"type,omitempty"`
Title string `bson:"title,omitempty"`
Image string `bson:"image,omitempty"`
Text string `bson:"text,omitempty"`
Modified int64 `bson:"modified,omitempty"`
Connections []Peer `bson:"connections,omitempty"`
}
func (o One) Query() One {
return One{Name: o.Name}
}
func (o One) Peers() []string {
names := make([]string, len(o.Connections))
for i := range o.Connections {
names[i] = o.Connections[i].Name
}
return names
}