Documentation ¶
Index ¶
Constants ¶
const ( PostTextField humus.Predicate = "Post.text" PostDatePublishedField humus.Predicate = "Post.datePublished" )
Generating constant field values.
const ( QuestionTitleField humus.Predicate = "Question.title" QuestionFromField humus.Predicate = "Question.from" QuestionCommentsField humus.Predicate = "Question.comments" QuestionTextField humus.Predicate = "Post.text" QuestionDatePublishedField humus.Predicate = "Post.datePublished" )
Generating constant field values.
const ( CommentFromField humus.Predicate = "Comment.from" CommentTextField humus.Predicate = "Post.text" CommentDatePublishedField humus.Predicate = "Post.datePublished" )
Generating constant field values.
const ( UserNameField humus.Predicate = "User.name" UserEmailField humus.Predicate = "User.email" )
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 CommentFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Comment.from", 0|humus.MetaObject), MakeField("Post.text", 0), MakeField("Post.datePublished", 0)})
var ErrorFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Error.message", 0), MakeField("Error.errorType", 0), MakeField("Error.time", 0)})
var PostFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Post.text", 0), MakeField("Post.datePublished", 0)})
Functions ¶
Types ¶
type Comment ¶
type Comment struct { //This line declares basic properties for a database node. humus.Node //List of interfaces implemented. Post //Regular fields From *User `json:"from" predicate:"Comment.from,omitempty"` }
//Values returns all the scalar values for this node.
func (r *Question) Values() humus.DNode{ var m QuestionScalars m.Title= r.Title m.Text= r.Text m.DatePublished= r.DatePublished 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 *Question) MapValues() humus.Mapper { var m = make(map[string]interface{}) m["Question.title"]= r.Title m["Post.text"]= r.Text m["Post.datePublished"]= r.DatePublished if r.Uid != "" { m["uid"] = r.Uid } r.SetType() m["dgraph.type"] = r.Type return m }
//QuestionScalars is simply to avoid a map[string]interface{} //It is a mirror of the previous struct with all scalar values.
type QuestionScalars struct { humus.Node Title string `json:"Question.title,omitempty"` Text string `json:"Post.text,omitempty"` DatePublished *time.Time `json:"Post.datePublished,omitempty"`
}
func (s *QuestionScalars) Values() humus.DNode { return s }
func (s *QuestionScalars) Fields() humus.FieldList { return QuestionFields }
End of model.template
func (*Comment) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *Comment) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*Comment) Recurse ¶
Recurse iterates through the node and allocates type and UID to pointer nodes.
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 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 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"`
}
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 Post ¶
type Post struct { //This line declares basic properties for a database node. humus.Node Text string `json:"text" predicate:"Post.text,omitempty"` DatePublished *time.Time `json:"datePublished" predicate:"Post.datePublished,omitempty"` }
Created from a GraphQL interface.
func (*Post) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *Post) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*Post) Recurse ¶
Recurse iterates through the node and allocates type and UID to pointer nodes.
type Question ¶
type Question struct { //This line declares basic properties for a database node. humus.Node //List of interfaces implemented. Post //Regular fields Title string `json:"title" predicate:"Question.title,omitempty"` From *User `json:"from" predicate:"Question.from,omitempty"` Comments []*Comment `json:"comments" predicate:"Question.comments,omitempty"` }
//Values returns all the scalar values for this node.
func (r *Post) Values() humus.DNode{ var m PostScalars m.Text= r.Text m.DatePublished= r.DatePublished 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 *Post) MapValues() humus.Mapper { var m = make(map[string]interface{}) m["Post.text"]= r.Text m["Post.datePublished"]= r.DatePublished if r.Uid != "" { m["uid"] = r.Uid } r.SetType() m["dgraph.type"] = r.Type return m }
//PostScalars is simply to avoid a map[string]interface{} //It is a mirror of the previous struct with all scalar values.
type PostScalars struct { humus.Node Text string `json:"Post.text,omitempty"` DatePublished *time.Time `json:"Post.datePublished,omitempty"`
}
func (s *PostScalars) Values() humus.DNode { return s }
func (s *PostScalars) Fields() humus.FieldList { return PostFields }
End of model.template
func (*Question) GetType ¶
SaveValues saves the node values that do not contain any references to other objects. Not needed for now.
func (r *Question) SaveValues(ctx context.Context, txn *humus.Txn) error { mut := humus.CreateMutation(r.Values(), humus.MutateSet) _,err := txn.Mutate(ctx, mut) return err }
func (*Question) 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"` }
//Values returns all the scalar values for this node.
func (r *Comment) Values() humus.DNode{ var m CommentScalars m.Text= r.Text m.DatePublished= r.DatePublished 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 *Comment) MapValues() humus.Mapper { var m = make(map[string]interface{}) m["Post.text"]= r.Text m["Post.datePublished"]= r.DatePublished if r.Uid != "" { m["uid"] = r.Uid } r.SetType() m["dgraph.type"] = r.Type return m }
//CommentScalars is simply to avoid a map[string]interface{} //It is a mirror of the previous struct with all scalar values.
type CommentScalars struct { humus.Node Text string `json:"Post.text,omitempty"` DatePublished *time.Time `json:"Post.datePublished,omitempty"`
}
func (s *CommentScalars) Values() humus.DNode { return s }
func (s *CommentScalars) Fields() humus.FieldList { return CommentFields }
End of model.template
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.