gen

package
v0.0.0-...-8b81d4d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PostTextField          humus.Predicate = "Post.text"
	PostDatePublishedField humus.Predicate = "Post.datePublished"
)

Generating constant field values.

View Source
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.

View Source
const (
	CommentFromField          humus.Predicate = "Comment.from"
	CommentTextField          humus.Predicate = "Post.text"
	CommentDatePublishedField humus.Predicate = "Post.datePublished"
)

Generating constant field values.

View Source
const (
	UserNameField  humus.Predicate = "User.name"
	UserEmailField humus.Predicate = "User.email"
)

Generating constant field values.

View Source
const (
	ErrorMessageField   humus.Predicate = "Error.message"
	ErrorErrorTypeField humus.Predicate = "Error.errorType"
	ErrorTimeField      humus.Predicate = "Error.time"
)

Generating constant field values.

Variables

View Source
var CommentFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Comment.from", 0|humus.MetaObject), MakeField("Post.text", 0), MakeField("Post.datePublished", 0)})
View Source
var ErrorFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Error.message", 0), MakeField("Error.errorType", 0), MakeField("Error.time", 0)})
View Source
var PostFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Post.text", 0), MakeField("Post.datePublished", 0)})
View Source
var QuestionFields humus.Fields = humus.FieldList([]humus.Field{MakeField("Question.title", 0), MakeField("Question.from", 0|humus.MetaObject), MakeField("Question.comments", 0|humus.MetaObject|humus.MetaList), MakeField("Post.text", 0), MakeField("Post.datePublished", 0)})
View Source
var UserFields humus.Fields = humus.FieldList([]humus.Field{MakeField("User.name", 0), MakeField("User.email", 0)})

Functions

func GetField

func GetField(name humus.Predicate) humus.Field

func GetGlobalFields

func GetGlobalFields() map[humus.Predicate]humus.Field

func MakeField

func MakeField(name humus.Predicate, flags humus.FieldMeta) humus.Field

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) AsPost

func (r *Comment) AsPost() *Post

func (*Comment) Facets

func (r *Comment) Facets() []string

func (*Comment) Fields

func (r *Comment) Fields() humus.Fields

Fields returns all Scalar fields for this value.

func (*Comment) GetType

func (r *Comment) GetType() []string

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

func (r *Comment) Recurse(counter int) int

Recurse iterates through the node and allocates type and UID to pointer nodes.

func (*Comment) Relative

func (r *Comment) Relative() *Comment

Relative returns a new Comment containing only the node component of it, useful in saving edges while ensuring data stability.

func (*Comment) SetType

func (r *Comment) SetType()

Sets the types. This DOES NOT include interfaces! as they are set in dgraph already.

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) Facets

func (r *Error) Facets() []string

func (*Error) Fields

func (r *Error) Fields() humus.Fields

Fields returns all Scalar fields for this value.

func (*Error) GetType

func (r *Error) GetType() []string

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

func (r *Error) Recurse(counter int) int

Recurse iterates through the node and allocates type and UID to pointer nodes.

func (*Error) Relative

func (r *Error) Relative() *Error

Relative returns a new Error containing only the node component of it, useful in saving edges while ensuring data stability.

func (*Error) SetType

func (r *Error) SetType()

Sets the types. This DOES NOT include interfaces! as they are set in dgraph already.

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) Facets

func (r *Post) Facets() []string

func (*Post) Fields

func (r *Post) Fields() humus.Fields

Fields returns all Scalar fields for this value.

func (*Post) GetType

func (r *Post) GetType() []string

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

func (r *Post) Recurse(counter int) int

Recurse iterates through the node and allocates type and UID to pointer nodes.

func (*Post) Relative

func (r *Post) Relative() *Post

Relative returns a new Post containing only the node component of it, useful in saving edges while ensuring data stability.

func (*Post) SetType

func (r *Post) SetType()

Sets the types. This DOES NOT include interfaces! as they are set in dgraph already.

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) AsPost

func (r *Question) AsPost() *Post

func (*Question) Facets

func (r *Question) Facets() []string

func (*Question) Fields

func (r *Question) Fields() humus.Fields

Fields returns all Scalar fields for this value.

func (*Question) GetType

func (r *Question) GetType() []string

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

func (r *Question) Recurse(counter int) int

Recurse iterates through the node and allocates type and UID to pointer nodes.

func (*Question) Relative

func (r *Question) Relative() *Question

Relative returns a new Question containing only the node component of it, useful in saving edges while ensuring data stability.

func (*Question) SetType

func (r *Question) SetType()

Sets the types. This DOES NOT include interfaces! as they are set in dgraph already.

type Type

type Type int

Start new enum.

const (
	First Type = iota
	Second
)

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) Facets

func (r *User) Facets() []string

func (*User) Fields

func (r *User) Fields() humus.Fields

Fields returns all Scalar fields for this value.

func (*User) GetType

func (r *User) GetType() []string

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

func (r *User) Recurse(counter int) int

Recurse iterates through the node and allocates type and UID to pointer nodes.

func (*User) Relative

func (r *User) Relative() *User

Relative returns a new User containing only the node component of it, useful in saving edges while ensuring data stability.

func (*User) SetType

func (r *User) SetType()

Sets the types. This DOES NOT include interfaces! as they are set in dgraph already.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL