Documentation ¶
Index ¶
Constants ¶
const ( EventNameField humus.Predicate = "Event.name" EventAttendingField humus.Predicate = "Event.attending" EventPricesField humus.Predicate = "Event.prices" EventDescriptionField humus.Predicate = "Event.description" EventPremiumField humus.Predicate = "~Event.attending|premium" )
Generating constant field values.
const ( UserNameField humus.Predicate = "User.name" UserEmailField humus.Predicate = "User.email" UserFullNameField humus.Predicate = "User.fullName" UserAttendingField humus.Predicate = "~Event.attending" UserPremiumField humus.Predicate = "Event.attending|premium" )
Generating constant field values.
const ( ErrorMessageField humus.Predicate = "Error.message" ErrorErrorTypeField humus.Predicate = "Error.errorType" ErrorTimeField humus.Predicate = "Error.time" )
Generating constant field values.
Variables ¶
var ErrorFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Error.message", 0), MakeField("Error.errorType", 0), MakeField("Error.time", 0)})
var EventFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Event.name", 0), MakeField("Event.attending", 0|humus.MetaObject|humus.MetaList|humus.MetaReverse), MakeField("Event.prices", 0|humus.MetaList), MakeField("Event.description", 0), MakeField("~Event.attending|premium", 0|humus.MetaFacet)})
Functions ¶
func AddUserToEvent ¶
Adds a user to an event from a http endpoint. Premium facet.
Types ¶
type Error ¶
type Error struct { //This line declares basic properties for a database node. humus.Node //Regular fields Message string `json:"message" predicate:"Error.message,omitempty"` ErrorType string `json:"errorType" predicate:"Error.errorType,omitempty"` Time *time.Time `json:"time" predicate:"Error.time,omitempty"` }
//Values returns all the scalar values for this node.
func (r *User) Values() humus.DNode{ var m UserScalars m.Name= r.Name m.Email= r.Email m.FullName= r.FullName m.Premium= r.Premium r.SetType() m.Node = r.Node return &m }
//Values returns all the scalar values for this node. //Note that this completely ignores any omitempty tags so use with care.
func (r *User) MapValues() humus.Mapper { var m = make(map[string]interface{}) m["User.name"]= r.Name m["User.email"]= r.Email m["User.fullName"]= r.FullName m["Event.attending|premium"]= r.Premium if r.Uid != "" { m["uid"] = r.Uid } r.SetType() m["dgraph.type"] = r.Type return m }
//UserScalars is simply to avoid a map[string]interface{} //It is a mirror of the previous struct with all scalar values.
type UserScalars struct { humus.Node Name string `json:"User.name,omitempty"` Email string `json:"User.email,omitempty"` FullName string `json:"User.fullName,omitempty"` Premium int `json:"Event.attending|premium,omitempty"`
}
func (s *UserScalars) Values() humus.DNode { return s }
func (s *UserScalars) Fields() humus.FieldList { return UserFields }
End of model.template
func (*Error) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *Error) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*Error) Recurse ¶
Recurse iterates through the node and allocates type and UID to pointer nodes.
type Event ¶
type Event struct { //This line declares basic properties for a database node. humus.Node //Regular fields Name string `json:"name" predicate:"Event.name,omitempty"` Attending []*User `json:"attending" predicate:"Event.attending,omitempty"` Prices []int `json:"prices" predicate:"Event.prices,omitempty"` Description string `json:"description" predicate:"Event.description,omitempty"` Premium int `json:"premium" predicate:"~Event.attending|premium,omitempty"` }
func (*Event) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *Event) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*Event) Recurse ¶
Recurse iterates through the node and allocates type and UID to pointer nodes.
type User ¶
type User struct { //This line declares basic properties for a database node. humus.Node //Regular fields Name string `json:"name" predicate:"User.name,omitempty"` Email string `json:"email" predicate:"User.email,omitempty"` FullName string `json:"fullName" predicate:"User.fullName,omitempty"` Attending []*Event `json:"attending" predicate:"~Event.attending,omitempty"` Premium int `json:"premium" predicate:"Event.attending|premium,omitempty"` }
//Values returns all the scalar values for this node.
func (r *Event) Values() humus.DNode{ var m EventScalars m.Name= r.Name m.Prices= r.Prices m.Description= r.Description m.Premium= r.Premium r.SetType() m.Node = r.Node return &m }
//Values returns all the scalar values for this node. //Note that this completely ignores any omitempty tags so use with care.
func (r *Event) MapValues() humus.Mapper { var m = make(map[string]interface{}) m["Event.name"]= r.Name m["Event.prices"]= r.Prices m["Event.description"]= r.Description m["~Event.attending|premium"]= r.Premium if r.Uid != "" { m["uid"] = r.Uid } r.SetType() m["dgraph.type"] = r.Type return m }
//EventScalars is simply to avoid a map[string]interface{} //It is a mirror of the previous struct with all scalar values.
type EventScalars struct { humus.Node Name string `json:"Event.name,omitempty"` Prices []int `json:"Event.prices,omitempty"` Description string `json:"Event.description,omitempty"` Premium int `json:"~Event.attending|premium,omitempty"`
}
func (s *EventScalars) Values() humus.DNode { return s }
func (s *EventScalars) Fields() humus.FieldList { return EventFields }
End of model.template
func GetUserWithAttending ¶
func (*User) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *User) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*User) Recurse ¶
Recurse iterates through the node and allocates type and UID to pointer nodes.