data

package
v0.0.0-...-da7ae81 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2014 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Copyright (c) 2014 André Luiz Alves Moraes

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

data holds the implementation of the postgresql backend

Index

Constants

View Source
const (
	InvalidGid = uint64(0)
	InvalidKid = uint32(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Db

type Db interface {
	Querier
	Begin() (Transaction, error)
	Close() error
}

type Keyword

type Keyword struct {
	Gid  uint32
	Name string
}

type Node

type Node struct {
	Gid        uint64
	Name       string
	Attributes string
}

type Querier

type Querier interface {
	QueryRow(query string, args ...interface{}) *sql.Row
	Query(query string, args ...interface{}) (*sql.Rows, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
}

type Relation

type Relation struct {
	FromGid        uint64
	FromName       string
	FromAttributes string

	ToGid        uint64
	ToName       string
	ToAttributes string

	Attributes string
	Field      uint32
	Name       string
}

func (*Relation) CopyFromData

func (r *Relation) CopyFromData(n *Node)

func (*Relation) CopyToData

func (r *Relation) CopyToData(n *Node)

func (*Relation) Set

func (r *Relation) Set(subject *Node, object string, predicate *Node) *Relation

type RelationSet

type RelationSet []*Relation

func (*RelationSet) Push

func (r *RelationSet) Push(rel *Relation)

type Repo

type Repo struct {
	Db          Db
	Transaction Transaction

	AutoCommit bool
	// contains filtered or unexported fields
}

func (*Repo) AbortPending

func (r *Repo) AbortPending() error

func (*Repo) ActiveQuerier

func (r *Repo) ActiveQuerier() Querier

func (*Repo) Begin

func (r *Repo) Begin() bool

func (*Repo) Close

func (r *Repo) Close() error

func (*Repo) Connect

func (nr *Repo) Connect(user, password, dbname, host string) error

func (*Repo) Create

func (nr *Repo) Create() error

func (*Repo) DeleteAll

func (nr *Repo) DeleteAll() error

DeleteAll remove all nodes and relations from the database but keep all keywords

func (*Repo) Drop

func (nr *Repo) Drop() error

func (*Repo) End

func (r *Repo) End() error

func (*Repo) Err

func (r *Repo) Err() error

func (*Repo) FetchNode

func (nr *Repo) FetchNode(name string, gid uint64, out *Node) error

func (*Repo) FetchRelation

func (r *Repo) FetchRelation(from, to uint64, name string, out *Relation) error

func (*Repo) Keyword

func (nr *Repo) Keyword(id interface{}, out *Keyword) error

func (*Repo) SaveKeyword

func (nr *Repo) SaveKeyword(kw *Keyword) error

func (*Repo) SaveNode

func (nr *Repo) SaveNode(node *Node) error

func (*Repo) SaveRelation

func (r *Repo) SaveRelation(rel *Relation) error

func (*Repo) Walk

func (r *Repo) Walk(from uint64, name string, out RelationSet) (RelationSet, error)

type Transaction

type Transaction interface {
	Querier
	Rollback() error
	Commit() error
}

Jump to

Keyboard shortcuts

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