36 lines
1.0 KiB
Go
36 lines
1.0 KiB
Go
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" json:"name,omitempty"`
|
|
Type string `bson:"type,omitempty" json:"type,omitempty"`
|
|
Title string `bson:"title,omitempty" json:"title,omitempty"`
|
|
Image string `bson:"image,omitempty" json:"image,omitempty"`
|
|
Text string `bson:"text,omitempty" json:"text,omitempty"`
|
|
Relationship string `bson:"relationship,omitempty" json:"relationship,omitempty"`
|
|
Modified int64 `bson:"modified,omitempty" json:"modified,omitempty"`
|
|
Connections []One `bson:"connections,omitempty" json:"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
|
|
}
|