Documentation ¶
Overview ¶
A basic Go interface to Oracle Berkeley DB XML.
Index ¶
- func Check(query string, namespaces ...Namespace) error
- func Version() (major, minor, patch int)
- type Db
- func (db *Db) All() (*Docs, error)
- func (db *Db) Close()
- func (db *Db) Get(name string) (string, error)
- func (db *Db) Merge(filename string, replace bool) error
- func (db *Db) Prepare(query string, namespaces ...Namespace) (*Query, error)
- func (db *Db) PrepareRaw(query string, namespaces ...Namespace) (*Query, error)
- func (db *Db) PutFile(filename string, replace bool) error
- func (db *Db) PutXml(name string, data string, replace bool) error
- func (db *Db) Query(query string, namespaces ...Namespace) (*Docs, error)
- func (db *Db) QueryRaw(query string, namespaces ...Namespace) (*Docs, error)
- func (db *Db) Remove(name string) error
- func (db *Db) Size() (uint64, error)
- type Docs
- type Namespace
- type Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Db ¶
type Db struct {
// contains filtered or unexported fields
}
A database connection.
func Open ¶
Open a database.
Attempt to open the database in read+write mode. If that fails, open in read-only mode.
Call db.Close() to ensure all write operations to the database are finished, before terminating the program.
func OpenReadWrite ¶
Open a database in read+write mode.
Call db.Close() to ensure all write operations to the database are finished, before terminating the program.
func (*Db) All ¶
Get all xml documents from the database.
Example:
docs, err := db.All() if err != nil { fmt.Println(err) } else { for docs.Next() { fmt.Println(docs.Name(), docs.Content()) } if err := docs.Error(); err != nil { fmt.Println(err) } }
func (*Db) Close ¶
func (db *Db) Close()
Close the database.
This flushes all write operations to the database.
This is called automaticly on garbage collection. Note that teminating the program does not call the garbage collector.
func (*Db) Prepare ¶
Prepare an XPATH query that runs on the default collection.
The query can be run multiple times, and a running query can be cancelled by query.Cancel()
func (*Db) PrepareRaw ¶ added in v1.3.0
Prepare an XPATH query without setting the default collection.
The query can be run multiple times, and a running query can be cancelled by query.Cancel()
func (*Db) Query ¶
Get all xml documents that match the XPATH query from the database.
Example:
docs, err := db.Query(xpath_query) if err != nil { fmt.Println(err) } else { for docs.Next() { fmt.Println(docs.Name(), docs.Content()) } if err := docs.Error(); err != nil { fmt.Println(err) } }
type Docs ¶
type Docs struct {
// contains filtered or unexported fields
}
An iterator over xml documents in the database.
func (*Docs) Close ¶
func (docs *Docs) Close()
Close iterator over xml documents in the database, that was returned by db.All(), db.Query(query), or query.Run().
This is called automaticly if docs.Next() reaches false, but you can also call it inside a loop to exit it prematurely:
docs, _ := db.All() for docs.Next() { fmt.Println(docs.Name(), docs.Content()) if some_condition { docs.Close() } }
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
A prepared query that can be run multiple times and interrupted while running.