Documentation
¶
Index ¶
- Variables
- func AddSchema(schema string)
- func Close()
- func FindConceptUID(title string, context *Context) (uint64, error)
- func Init(args []string)
- func InitializeDatabaseClient(ip string, port string)
- func Query(name string, data interface{}) (*protos.Response, error)
- func QueryAndUnmarshal(name string, data interface{}, result interface{}) error
- type Comment
- type Concept
- type Context
- type DatabaseClient
- type Discussion
- type Perspective
- type Statement
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrConceptAlreadyExists = errors.New("concept already exists")
ErrConceptAlreadyExists is given on new concept creation, when a concept of that name and context already exists.
var ErrContextAlreadyExists = errors.New("context already exists")
ErrContextAlreadyExists self explanatory
var ErrEmptyLabel = errors.New("no label given")
ErrEmptyLabel is returned when trying to query for empty label
var ErrEmptyStatementSlice = errors.New("cannot generate statements from empty list")
ErrEmptyStatementSlice self explanatory
var ErrIncompleteUIDMap = errors.New("cannot find label in assigned uids")
ErrIncompleteUIDMap self explanatory
var ErrNoConceptFound = errors.New("no concept found")
ErrNoConceptFound is given when no concepts are found
var ErrNoPerspectivesFound = errors.New("no perspectives found")
ErrNoPerspectivesFound is given when no perspectives are found
var ErrNoStatements = errors.New("cannot create new perspective with no statements")
ErrNoStatements is given on creating a new perspective, with a zero length statement slice.
var ErrPasswordIncorrect = errors.New("password is incorrect")
ErrPasswordIncorrect is given when password is incorrect
var ErrResponseQuery = errors.New("database error: query")
ErrResponseQuery occurs on response query error, datasensitive version
var ErrResponseUnmarshalling = errors.New("database error: unmarshalling")
ErrResponseUnmarshalling occurs on response unmarshalling error, datasensitive version.
var ErrTooManyConcepts = errors.New("too many concepts")
ErrTooManyConcepts is given when too many concepts are found in a query expecting only one.
var ErrUsernameAlreadyExists = errors.New("username already exists")
ErrUsernameAlreadyExists is given on registration if user with username already exists
var ErrUsernameNotFound = errors.New("username not found")
ErrUsernameNotFound is given when queried username is not found
Functions ¶
func AddSchema ¶
func AddSchema(schema string)
AddSchema adds the given schema through the databaseclient
func FindConceptUID ¶
FindConceptUID finds the UID of the concept with the given title in the given context, if context is nil, and there exists only one concept of the title, that concept UID is returned, if there exists more concepts an error is returned.
func InitializeDatabaseClient ¶
InitializeDatabaseClient intializes the database client, this must be called before running other database functions.
func QueryAndUnmarshal ¶
QueryAndUnmarshal queries with the template of name, and the data. then unmarshals the result into the given result interface.
Types ¶
type Comment ¶
type Comment struct {
Text string `json:"text"`
UID uint64 `json:"_uid_"`
UIDString string `json:"uidstring"`
}
Comment TODO
type Concept ¶
type Concept struct {
Title string `json:"title"`
UID uint64 `json:"_uid_"`
Context *Context `json:"context"`
Perspectives []Perspective `json:"perspectives"`
}
Concept TODO
func GetConcepts ¶
GetConcepts will given a concept title return a slice of concepts with the given title, differing in context
func NewConcept ¶
NewConcept inserts a new concept into the database and returns the concept struct.
func (*Concept) NewPerspective ¶
func (c *Concept) NewPerspective(texts []string) (*Perspective, error)
NewPerspective inserts a new perspective into the database and returns the concept struct.
type DatabaseClient ¶
DatabaseClient holds the dgraph client, and a function to gracefully close
func NewDatabaseClient ¶
func NewDatabaseClient(ip string, port string) *DatabaseClient
NewDatabaseClient returns a dgraph client and the function to close it.
type Discussion ¶
type Discussion struct {
Text string `json:"text"`
DTitle string `json:"dtitle"`
UID uint64 `json:"_uid_"`
UIDString string `json:"uidstring"`
}
Discussion TODO
func NewDiscussion ¶
func NewDiscussion(user *User, dTitle string, text string, subjectUIDString string) (*Discussion, error)
NewDiscussion creates a new discussion for the subject corresponding to the uidString, this discussion will have the given title. title is not unique.
func (*Discussion) NewComment ¶
func (d *Discussion) NewComment(user *User, text string) (*Comment, error)
NewComment will create a new comment by the given user on the given discussion.
type Perspective ¶
type Perspective struct {
UID uint64 `json:"_uid_"`
UIDString string
Statement *Statement `json:"statement"`
}
Perspective TODO
type Statement ¶
type Statement struct {
UID uint64 `json:"_uid_"`
UIDString string `json:"uidstring"`
Text string `json:"text"`
Next *Statement `json:"next"`
}
Statement TODO