Documentation ¶
Overview ¶
Package numbersix implements a triple store.
It is build on top of sqlite and uses encoding/json to marshal values.
Index ¶
- type AboutQuery
- type AllQuery
- type AnyQuery
- type BoundOrderedQuery
- type DB
- func (d *DB) Any(query AnyQuery) (ok bool, err error)
- func (d *DB) Close() error
- func (d *DB) DeletePredicate(subject, predicate string) error
- func (d *DB) DeleteSubject(subject string) error
- func (d *DB) DeleteValue(subject, predicate string, value interface{}) error
- func (d *DB) List(query Query) (results []Triple, err error)
- func (d *DB) Set(subject, predicate string, value interface{}, more ...interface{}) error
- func (d *DB) SetMany(subject, predicate string, values interface{}) error
- func (d *DB) SetProperties(subject string, properties map[string][]interface{}) error
- type Group
- type OrderedQuery
- type Query
- type Triple
- type WhereQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AboutQuery ¶
type AboutQuery struct {
// contains filtered or unexported fields
}
func About ¶
func About(subject string) *AboutQuery
About is a query that returns all triples with a particular subject.
func (*AboutQuery) Where ¶
func (q *AboutQuery) Where(predicate string, value interface{}) *AboutQuery
Where adds a condition to the query so that only triples for subjects that have the predicate and value are returned.
type AnyQuery ¶
type AnyQuery interface {
// contains filtered or unexported methods
}
AnyQuery defines conditions for triples that Any should match.
type BoundOrderedQuery ¶
type BoundOrderedQuery struct {
// contains filtered or unexported fields
}
func After ¶
func After(predicate string, value interface{}) *BoundOrderedQuery
After is a query that returns triples for a subject having a triple with the predicate and a value after that provided. The returned triples will be ordered such that the subjects are ascending by the predicate's value. For example, if we had triples:
("a", "name", "John") ("a", "age", 20) ("b", "name", "Jane") ("b", "age", 24) ("c", "name", "Kevin") ("c", "age", 23)
Then a query of After("age", 22), would give us triples:
("c", "age", 23) ("c", "name", "Kevin") ("b", "age", 24) ("b", "name", "Jane")
func Before ¶
func Before(predicate string, value interface{}) *BoundOrderedQuery
Before is like After, but the triples returned will have values less than the value given, and will be ordered descending on the predicate.
func (*BoundOrderedQuery) Limit ¶
func (q *BoundOrderedQuery) Limit(count int) *BoundOrderedQuery
Limit adds a condition to the query so that only triples for count subjects are returned.
func (*BoundOrderedQuery) Where ¶
func (q *BoundOrderedQuery) Where(predicate string, value interface{}) *BoundOrderedQuery
Where adds a condition to the query so that only triples for subjects that have the predicate and value are returned.
func (*BoundOrderedQuery) Without ¶
func (q *BoundOrderedQuery) Without(predicate string) *BoundOrderedQuery
Without adds a condition to the query so that only triples for subjects that do not have the predicate are returned.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB stores triples.
func (*DB) DeletePredicate ¶
DeletePredicate removes all triples with the subject and predicate given. If none exist, then this does nothing.
func (*DB) DeleteSubject ¶
DeleteSubject removes all triples for the subject given. If none exist, then this does nothing.
func (*DB) DeleteValue ¶
DeleteValue removes the triple for the (subject, predicate, value) given. If none exist, then this does nothing.
func (*DB) Set ¶
Set the value(s) for a subject and predicate. Only unique values are stored per (subject, predicate) combination, and insertion order is not retained.
type OrderedQuery ¶
type OrderedQuery struct {
// contains filtered or unexported fields
}
func Ascending ¶
func Ascending(on string) *OrderedQuery
func Descending ¶
func Descending(on string) *OrderedQuery
func (*OrderedQuery) Where ¶
func (q *OrderedQuery) Where(predicate string, value interface{}) *OrderedQuery
Where adds a condition to the query so that only triples for subjects that have the predicate and value are returned.
type Query ¶
type Query interface {
// contains filtered or unexported methods
}
Query defines conditions for triples that List should return.
type WhereQuery ¶
type WhereQuery struct {
// contains filtered or unexported fields
}
func Begins ¶
func Begins(predicate string, value interface{}) *WhereQuery
Begins is a query that returns all triples with a particular predicate that begins with the value.
func Where ¶
func Where(predicate string, value interface{}) *WhereQuery
Where is a query that returns all triples with a particular predicate-value.
func (*WhereQuery) Has ¶
func (q *WhereQuery) Has(predicate string) *WhereQuery
Has adds a condition to the query so that only triples for subjects that have the predicate (with any value) are returned.
func (*WhereQuery) Where ¶
func (q *WhereQuery) Where(predicate string, value interface{}) *WhereQuery
Where adds a condition to the query so that only triples for subjects that have the predicate and value are returned.
func (*WhereQuery) Without ¶
func (q *WhereQuery) Without(predicate string) *WhereQuery
Without adds a condition to the query so that only triples for subjects that do not have the predicate are returned.