Documentation ¶
Index ¶
- Constants
- Variables
- func MarshalContent(o interface{}) string
- func RegException(class string, fnc func(e Exception) Exception)
- func RegisterMapDecoderHook(hook mapstructure.DecodeHookFunc)
- func RegisterProto(name string, dial func(addr string) (DBConnection, error))
- func RegisterRecordFormat(name string, fnc func() RecordSerializer)
- func SerializeAnyStreamable(o CustomSerializable) ([]byte, error)
- func SetDefaultRecordFormat(name string)
- func SetRetryCountConcurrent(n int)
- type Admin
- func (a *Admin) Close() error
- func (a *Admin) CreateDatabase(name string, dbType DatabaseType, storageType StorageType) error
- func (a *Admin) DatabaseExists(name string, storageType StorageType) (bool, error)
- func (a *Admin) DropDatabase(name string, storageType StorageType) error
- func (a *Admin) ListDatabases() (map[string]string, error)
- type BinaryRecordFormat
- type BytesRecord
- func (r BytesRecord) Content() ([]byte, error)
- func (r *BytesRecord) Fill(rid RID, version int, content []byte) error
- func (r BytesRecord) GetIdentity() RID
- func (r BytesRecord) GetRecord() interface{}
- func (r BytesRecord) RecordType() RecordType
- func (r *BytesRecord) SetRID(rid RID)
- func (r *BytesRecord) SetVersion(v int)
- func (r BytesRecord) String() string
- func (r BytesRecord) Version() int
- type Classer
- type Client
- type CustomSerializable
- type DBAdmin
- type DBConnection
- type DBSession
- type Database
- func (db *Database) AddCluster(name string) (int16, error)
- func (db *Database) AddClusterWithID(name string, clusterID int16) (int16, error)
- func (db *Database) CallScriptFunc(name string, params ...interface{}) Results
- func (db *Database) Close() error
- func (db *Database) ClustersCount(withDeleted bool, clusterNames ...string) (int64, error)
- func (db *Database) Command(cmd OCommandRequestText) Results
- func (db *Database) CountRecords() (int64, error)
- func (db *Database) CreateRecord(rec ORecord) error
- func (db *Database) CreateScriptFunc(fnc Function) error
- func (db *Database) DeleteRecordByRID(rid RID, recVersion int) error
- func (db *Database) DeleteScriptFunc(name string) error
- func (db *Database) DropCluster(name string) error
- func (db *Database) GetClusterDataRange(clusterName string) (begin, end int64, err error)
- func (db *Database) GetCurDB() *ODatabase
- func (db *Database) GetRecordByRID(rid RID, fetchPlan FetchPlan, ignoreCache bool) (ORecord, error)
- func (db *Database) InitScriptFunc(fncs ...Function) (err error)
- func (db *Database) ReloadSchema() error
- func (db *Database) Size() (int64, error)
- func (db *Database) UpdateRecord(rec ORecord) error
- func (db *Database) UpdateScriptFunc(name string, script string) error
- type DatabaseType
- type Decimal
- type Deserializable
- type DocEntry
- type Document
- func (doc *Document) AddField(name string, field *DocEntry) *Document
- func (doc *Document) ClassName() string
- func (doc *Document) Content() ([]byte, error)
- func (doc *Document) FieldNames() []string
- func (doc *Document) Fields() map[string]*DocEntry
- func (doc *Document) FieldsArray() []*DocEntry
- func (doc *Document) Fill(rid RID, version int, content []byte) error
- func (doc *Document) FillClassNameIfNeeded(name string)
- func (doc *Document) From(o interface{}) error
- func (doc *Document) GetField(fname string) *DocEntry
- func (doc *Document) GetIdentity() RID
- func (doc *Document) GetRecord() interface{}
- func (doc *Document) RawContainsField(name string) bool
- func (doc *Document) RawSetField(name string, val interface{}, fieldType OType)
- func (doc *Document) RecordType() RecordType
- func (doc *Document) SetClassNameIfExists(name string)
- func (doc *Document) SetDirty(b bool)
- func (doc *Document) SetField(name string, val interface{}) *Document
- func (doc *Document) SetFieldWithType(name string, val interface{}, fieldType OType) *Document
- func (doc *Document) SetSerializer(ser RecordSerializer)
- func (doc *Document) String() string
- func (doc *Document) ToDocument() (*Document, error)
- func (doc *Document) ToMap() (map[string]interface{}, error)
- func (doc *Document) ToStruct(o interface{}) error
- type DocumentDeserializable
- type DocumentSerializable
- type ErrConcurrentModification
- type ErrInvalidConn
- type ErrMultipleRecords
- type ErrTypeSerialization
- type ErrUnsupportedConversion
- type Exception
- type FetchPlan
- type Function
- type FunctionCommand
- type GlobalPropertyFunc
- type MapSerializable
- type OClass
- type OCommandRequestText
- type ODatabase
- type OGlobalProperty
- type OIdentifiable
- type OIdentifiableCollection
- type OProperty
- type ORecord
- type OServerException
- type OType
- type RID
- func (rid *RID) FromStream(r io.Reader) error
- func (r RID) GetIdentity() RID
- func (r RID) GetRecord() interface{}
- func (rid RID) IsNew() bool
- func (rid RID) IsPersistent() bool
- func (rid RID) IsTemporary() bool
- func (r RID) IsValid() bool
- func (rid RID) Next() string
- func (rid RID) NextRID() RID
- func (rid RID) String() string
- func (rid RID) ToStream(w io.Writer) error
- type RecordFactory
- type RecordSerializer
- type RecordType
- type Results
- type RidBag
- type SQLCommand
- type SQLQuery
- type ScriptCommand
- type ScriptLang
- type Serializable
- type StorageType
- type StringRecordFormatAbs
- type UnknownException
Constants ¶
const ( // DefaultFetchPlan is an empty fetch plan. Let the database decide. Usually means "do not follow any links". DefaultFetchPlan = FetchPlan("") // NoFollow is a fetch plan that does not follow any links NoFollow = FetchPlan("*:0") // FollowAll is a fetch plan that follows all links FollowAll = FetchPlan("*:-1") )
const ( LangSQL = ScriptLang("sql") LangJS = ScriptLang("javascript") LangGroovy = ScriptLang("groovy") )
List of supported server-side script languages
const (
ProtoBinary = "binary"
)
Default protocols
Variables ¶
var ErrNoRecord = fmt.Errorf("no records returned, while expecting one")
ErrNoRecord is returned when trying to deserialize an empty result set into a single value.
var MaxConnections = 6
MaxConnections limits the number of opened connections.
var TagName = "mapstructure"
TagName is a name for a struct tag used for types conversion using reflect
Functions ¶
func MarshalContent ¶
func MarshalContent(o interface{}) string
MarshalContent is a helper for constructing SQL commands with CONTENT keyword. Shorthand for json.Marshal. Will panic on errors.
func RegException ¶
RegException registers a function to convert server exception based on it's class.
func RegisterMapDecoderHook ¶
func RegisterMapDecoderHook(hook mapstructure.DecodeHookFunc)
RegisterMapDecoderHook allows to register additional hook for map decoder
func RegisterProto ¶
func RegisterProto(name string, dial func(addr string) (DBConnection, error))
RegisterProto registers a new protocol for Dial command
func RegisterRecordFormat ¶
func RegisterRecordFormat(name string, fnc func() RecordSerializer)
RegisterRecordFormat registers RecordSerializer with a given class name
func SerializeAnyStreamable ¶
func SerializeAnyStreamable(o CustomSerializable) ([]byte, error)
SerializeAnyStreamable serializes a given object
func SetDefaultRecordFormat ¶
func SetDefaultRecordFormat(name string)
SetDefaultRecordFormat sets default record serializer
func SetRetryCountConcurrent ¶
func SetRetryCountConcurrent(n int)
SetRetryCountConcurrent sets a retry count when ErrConcurrentModification occurs.
n == 0 - use default value
n < 0 - no limit for retries
n > 0 - maximum of n retries
Types ¶
type Admin ¶
type Admin struct {
// contains filtered or unexported fields
}
Admin wraps a database management session.
func (*Admin) CreateDatabase ¶
func (a *Admin) CreateDatabase(name string, dbType DatabaseType, storageType StorageType) error
CreateDatabase creates a new database with given database type (Document or Graph) and storage type (Persistent or Volatile).
func (*Admin) DatabaseExists ¶
func (a *Admin) DatabaseExists(name string, storageType StorageType) (bool, error)
DatabaseExists checks if database with given name and storage type exists.
func (*Admin) DropDatabase ¶
func (a *Admin) DropDatabase(name string, storageType StorageType) error
DropDatabase removes database from the server.
type BinaryRecordFormat ¶
type BinaryRecordFormat struct {
// contains filtered or unexported fields
}
func (BinaryRecordFormat) FromStream ¶
func (f BinaryRecordFormat) FromStream(data []byte) (out ORecord, err error)
func (*BinaryRecordFormat) SetGlobalPropertyFunc ¶
func (f *BinaryRecordFormat) SetGlobalPropertyFunc(fnc GlobalPropertyFunc)
func (BinaryRecordFormat) String ¶
func (BinaryRecordFormat) String() string
type BytesRecord ¶
BytesRecord is a rawest representation of a record. It's schema less. Use this if you need to store []byte without matter about the content. Useful also to store multimedia contents and binary files.
func NewBytesRecord ¶
func NewBytesRecord() *BytesRecord
func (BytesRecord) Content ¶
func (r BytesRecord) Content() ([]byte, error)
func (*BytesRecord) Fill ¶
func (r *BytesRecord) Fill(rid RID, version int, content []byte) error
Fill sets identity, version and raw data of the record
func (BytesRecord) GetIdentity ¶
func (r BytesRecord) GetIdentity() RID
GetIdentity returns a record RID
func (BytesRecord) GetRecord ¶
func (r BytesRecord) GetRecord() interface{}
GetRecord returns a record data
func (BytesRecord) RecordType ¶
func (r BytesRecord) RecordType() RecordType
func (*BytesRecord) SetRID ¶
func (r *BytesRecord) SetRID(rid RID)
func (*BytesRecord) SetVersion ¶
func (r *BytesRecord) SetVersion(v int)
func (BytesRecord) String ¶
func (r BytesRecord) String() string
func (BytesRecord) Version ¶
func (r BytesRecord) Version() int
type Classer ¶
type Classer interface { // GetClassName return a Java class name for an object GetClassName() string }
Classer is an interface for object that have analogs in OrientDB Java code
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents connection to OrientDB server. It is safe for concurrent use.
func Dial ¶
Dial opens a new connection to OrientDB server.
For now, user must import protocol implementation, which will be used for connection:
import _ "gopkg.in/istreamdata/orientgo.v2/obinary"
Address must be in host:port format. Connection to OrientDB cluster is not supported yet.
Returned Client uses connection pool under the hood, so it can be shared between goroutines.
func (*Client) Auth ¶
Auth initiates a new administration session with OrientDB server, allowing to manage databases.
type CustomSerializable ¶
type CustomSerializable interface { Classer Serializable }
CustomSerializable is an interface for objects that can be sent on wire
type DBAdmin ¶
type DBAdmin interface { DatabaseExists(name string, storageType StorageType) (bool, error) CreateDatabase(name string, dbType DatabaseType, storageType StorageType) error DropDatabase(name string, storageType StorageType) error ListDatabases() (map[string]string, error) Close() error }
DBAdmin is a minimal interface for database management API implementation
type DBConnection ¶
type DBConnection interface { Auth(user, pass string) (DBAdmin, error) Open(name string, dbType DatabaseType, user, pass string) (DBSession, error) Close() error }
DBConnection is a minimal interface for OrientDB server API implementation
type DBSession ¶
type DBSession interface { Close() error Size() (int64, error) ReloadSchema() error GetCurDB() *ODatabase AddClusterWithID(clusterName string, id int16) (clusterID int16, err error) DropCluster(clusterName string) (err error) GetClusterDataRange(clusterName string) (begin, end int64, err error) ClustersCount(withDeleted bool, clusterNames ...string) (int64, error) CreateRecord(rec ORecord) (err error) DeleteRecordByRID(rid RID, recVersion int) error GetRecordByRID(rid RID, fetchPlan FetchPlan, ignoreCache bool) (rec ORecord, err error) UpdateRecord(rec ORecord) error CountRecords() (int64, error) Command(cmd CustomSerializable) (result interface{}, err error) }
DBSession is a minimal interface for database API implementation
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database wraps a database session. It is safe for concurrent use.
func (*Database) AddCluster ¶
AddCluster creates new cluster with given name and returns its ID.
func (*Database) AddClusterWithID ¶
AddClusterWithID creates new cluster with given cluster position and name
func (*Database) CallScriptFunc ¶
CallScriptFunc is a helper for calling server-side functions (especially JS). Ideally should be a shorthand for
db.Command(NewFunctionCommand(name, params...))
but it uses some workarounds to allow to return JS objects from that functions.
func (*Database) ClustersCount ¶
ClustersCount returns total count of records in given clusters
func (*Database) Command ¶
func (db *Database) Command(cmd OCommandRequestText) Results
Command executes command against current database. Example:
result := db.Command(NewSQLQuery("SELECT FROM V WHERE id = ?", id).Limit(10))
func (*Database) CountRecords ¶
CountRecords returns total records count.
func (*Database) CreateRecord ¶
CreateRecord saves a record to the database. Record RID and version will be changed.
func (*Database) CreateScriptFunc ¶
CreateScriptFunc is a helper for saving server-side functions to database.
func (*Database) DeleteRecordByRID ¶
DeleteRecordByRID removes a record from database
func (*Database) DeleteScriptFunc ¶
DeleteScriptFunc deletes server-side function with a given name from current database.
func (*Database) DropCluster ¶
DropCluster deletes cluster from database
func (*Database) GetClusterDataRange ¶
GetClusterDataRange returns the begin and end positions of data in the requested cluster.
func (*Database) GetRecordByRID ¶
GetRecordByRID returns a record using specified fetch plan. If ignoreCache is set to true implementations will not use local records cache and will fetch record from database.
func (*Database) InitScriptFunc ¶
InitScriptFunc is a helper for updating all server-side functions to specified state.
func (*Database) ReloadSchema ¶
ReloadSchema reloads documents schema from database.
func (*Database) UpdateRecord ¶
UpdateRecord updates given record in a database. Record version will be changed after the call.
type DatabaseType ¶
type DatabaseType string
DatabaseType defines database access type (Document or Graph)
const ( DocumentDB DatabaseType = "document" GraphDB DatabaseType = "graph" )
List of database access types
type Deserializable ¶
Deserializable is an interface for objects that can be deserialized from stream
type Document ¶
type Document struct { BytesRecord // contains filtered or unexported fields }
func NewDocument ¶
NewDocument should be called to create new Document objects, since some internal data structures need to be initialized before the Document is ready to use.
func NewDocumentFromRID ¶
NewDocumentFromRID creates new empty document with given RID.
func NewEmptyDocument ¶
func NewEmptyDocument() *Document
NewEmptyDocument creates new empty document.
func (*Document) AddField ¶
AddField adds a fully created field directly rather than by some of its attributes, as the other "Field" methods do. The same *Document is returned to allow call chaining.
func (*Document) FieldNames ¶
FieldNames returns the names of all the fields currently in this Document in "entry order". These fields may not have already been committed to the database.
func (*Document) FieldsArray ¶
FieldsArray return the OField objects in the Document in "entry order". There is some overhead to getting them in entry order, so if you don't care about that order, just access the Fields field of the Document struct directly.
func (*Document) FillClassNameIfNeeded ¶
func (*Document) From ¶
From sets Document fields to values provided in argument (which can be a map or a struct).
From uses TagName field tag to determine field name and conversion parameters. For now it supports only one special tag parameter: ",squash" which can be used to inline fields into parent struct.
func (*Document) GetField ¶
GetFieldByName looks up the OField in this document with the specified field. If no field is found with that name, nil is returned.
func (*Document) GetIdentity ¶
func (*Document) RawContainsField ¶
func (*Document) RawSetField ¶
func (*Document) RecordType ¶
func (doc *Document) RecordType() RecordType
func (*Document) SetClassNameIfExists ¶
func (*Document) SetField ¶
SetField is used to add a new field to a document. This will usually be done just before calling Save and sending it to the database. The field type will be inferred via type switch analysis on `val`. Use FieldWithType to specify the type directly. The same *Document is returned to allow call chaining.
func (*Document) SetFieldWithType ¶
FieldWithType is used to add a new field to a document. This will usually be done just before calling Save and sending it to the database. The `fieldType` must correspond one of the OrientDB type in the schema pkg constants. It will follow the same list as: https://github.com/orientechnologies/orientdb/wiki/Types The same *Document is returned to allow call chaining.
func (*Document) SetSerializer ¶
func (doc *Document) SetSerializer(ser RecordSerializer)
SetSerializer sets RecordSerializer for encoding/decoding a Document
func (*Document) ToDocument ¶
ToDocument implement DocumentSerializable interface. In this case, Document just returns itself.
type DocumentDeserializable ¶
DocumentDeserializable is an interface for objects that can be filled from Document
type DocumentSerializable ¶
DocumentSerializable is an interface for objects that can be converted to Document
type ErrConcurrentModification ¶
type ErrConcurrentModification struct {
Exception
}
func (ErrConcurrentModification) Error ¶
func (e ErrConcurrentModification) Error() string
type ErrInvalidConn ¶
type ErrInvalidConn struct {
Msg string
}
ErrInvalidConn is returned than DB functions are called without active DB connection
func (ErrInvalidConn) Error ¶
func (e ErrInvalidConn) Error() string
type ErrMultipleRecords ¶
ErrMultipleRecords is returned when trying to deserialize a result set with multiple records into a single value.
func (ErrMultipleRecords) Error ¶
func (e ErrMultipleRecords) Error() string
type ErrTypeSerialization ¶
type ErrTypeSerialization struct { Val interface{} Serializer interface{} }
ErrTypeSerialization represent serialization/deserialization error
func (ErrTypeSerialization) Error ¶
func (e ErrTypeSerialization) Error() string
type ErrUnsupportedConversion ¶
func (ErrUnsupportedConversion) Error ¶
func (e ErrUnsupportedConversion) Error() string
type Exception ¶
type Exception interface { error // Returns Java exception class ExcClass() string // Returns exception message ExcMessage() string }
Exception is an interface for Java-based Exceptions.
type FetchPlan ¶
type FetchPlan string
FetchPlan is an additional parameter to queries, that instructs DB how to handle linked documents.
The format is:
(field:depth)*
Field is the name of the field to specify the depth-level. Wildcard '*' means any fields.
Depth is the depth level to fetch. -1 means infinite, 0 means no fetch at all and 1-N the depth level value.
WARN: currently fetch plan have no effect on returned results, as records cache is not implemented yet.
type Function ¶
type Function struct { Name string Lang ScriptLang Params []string Idemp bool // is idempotent Code string }
Function is a server-side function description
type FunctionCommand ¶
type FunctionCommand struct {
// contains filtered or unexported fields
}
FunctionCommand is a command to call server-side function.
OCommandFunction in Java world.
func NewFunctionCommand ¶
func NewFunctionCommand(name string, params ...interface{}) FunctionCommand
NewFunctionCommand creates a new call request to server-side function with given name and arguments.
func (FunctionCommand) GetClassName ¶
func (rq FunctionCommand) GetClassName() string
GetClassName returns Java class name
type GlobalPropertyFunc ¶
type GlobalPropertyFunc func(id int) (OGlobalProperty, bool)
GlobalPropertyFunc is a function for getting global properties by id
type MapSerializable ¶
MapSerializable is an interface for objects that can be converted to map[string]interface{}
type OClass ¶
type OClass struct { Name string ShortName string Properties map[string]*OProperty DefaultClusterId int32 ClusterIds []int32 SuperClass string OverSize float32 StrictMode bool AbstractClass bool ClusterSelection string // OClusterSelectionStrategy in Java code - needed? CustomFields map[string]string }
func NewOClassFromDocument ¶
Should be passed an Document that comes from a load schema request to the database.
type OCommandRequestText ¶
type OCommandRequestText interface { CustomSerializable GetText() string }
OCommandRequestText is an interface for text-based database commands, which can be executed using database.Command function.
type ODatabase ¶
type ODatabase struct { Name string Type DatabaseType Classes map[string]*OClass }
ODatabase stores database metadata
type OGlobalProperty ¶
OGlobalProperty is used by OrientDB to efficiently store "property" (field) types and names (but not values) across all clusters in a database These are stored in record #0:1 of a database and loaded when the DBClient starts up. (TODO: it will also need to be updated when new fields are added at runtime)
func NewGlobalPropertyFromDocument ¶
func NewGlobalPropertyFromDocument(doc *Document) OGlobalProperty
based on how the Java client does it ; TODO: document usage
type OIdentifiable ¶
type OIdentifiable interface { GetIdentity() RID GetRecord() interface{} }
type OIdentifiableCollection ¶
type OIdentifiableCollection interface { Len() int OIdentifiableIterator() <-chan OIdentifiable }
type OProperty ¶
type OProperty struct { Id int32 Name string Fullname string // Classname.propertyName Type byte // corresponds to one of the type constants above NotNull bool Collate string // is OCollate in Java client Mandatory bool Min string Max string Regexp string CustomFields map[string]string Readonly bool }
OProperty roughly corresponds to OProperty in the Java client. It represents a property of a class in OrientDB. A property represents the metadata of a field. A field (OField) is the actual data of a field in an Document.
func NewOPropertyFromDocument ¶
NewOPropertyFromDocument creates a new OProperty from an Document that was created after a load schema call to the OrientDB server.
type ORecord ¶
type ORecord interface { OIdentifiable Fill(rid RID, version int, content []byte) error // TODO: put to separate interface? Content() ([]byte, error) Version() int SetVersion(v int) SetRID(rid RID) RecordType() RecordType }
func NewRecordOfType ¶
func NewRecordOfType(tp RecordType) ORecord
NewRecordOfType creates a new record of specified type
type OServerException ¶
type OServerException struct {
Exceptions []Exception
}
OServerException encapsulates Java-based Exceptions from the OrientDB server. OrientDB can return multiple exceptions for a single query/command, so they are all encapsulated in one OServerException object.
func (OServerException) Error ¶
func (e OServerException) Error() string
type OType ¶
type OType byte
OType is an enum for the various data types supported by OrientDB.
const ( BOOLEAN OType = 0 INTEGER OType = 1 SHORT OType = 2 LONG OType = 3 FLOAT OType = 4 DOUBLE OType = 5 DATETIME OType = 6 STRING OType = 7 BINARY OType = 8 // means []byte EMBEDDED OType = 9 EMBEDDEDLIST OType = 10 EMBEDDEDSET OType = 11 EMBEDDEDMAP OType = 12 LINK OType = 13 LINKLIST OType = 14 LINKSET OType = 15 LINKMAP OType = 16 BYTE OType = 17 TRANSIENT OType = 18 DATE OType = 19 CUSTOM OType = 20 DECIMAL OType = 21 LINKBAG OType = 22 ANY OType = 23 UNKNOWN OType = 255 // driver addition )
in alignment with: http://orientdb.com/docs/last/Types.html
func OTypeForValue ¶
func OTypeForValue(val interface{}) (ftype OType)
func OTypeFromString ¶
func (OType) ReflectKind ¶
func (OType) ReflectType ¶
type RID ¶
RID encapsulates the two aspects of an OrientDB RecordID - ClusterID:ClusterPos. ORecordId in Java world.
func MustParseRID ¶
MustParseRID is a version of ParseRID which panics on errors
func NewEmptyRID ¶
func NewEmptyRID() RID
NewEmptyRID returns an RID with the default "invalid" settings. Invalid settings indicate that the Document has not yet been saved to the DB (which assigns it a valid RID) or it indicates that it is not a true Document with a Class (e.g., it is a result of a Property query)
func NewRID ¶
NewRID creates a RID with given ClusterId and ClusterPos. It will check value for validity.
func NewRIDInCluster ¶
NewRIDInCluster creates an empty RID inside specified cluster
func (RID) GetIdentity ¶
GetIdentity implements OIdentifiable interface on RID
func (RID) IsPersistent ¶
func (RID) IsTemporary ¶
type RecordFactory ¶
type RecordFactory func() ORecord
RecordFactory is a function to create records of certain type
func GetRecordFactory ¶
func GetRecordFactory(tp RecordType) RecordFactory
GetRecordFactory returns RecordFactory for a given type
type RecordSerializer ¶
type RecordSerializer interface { // String, in case of RecordSerializer must return it's class name, as it will be sent to server String() string ToStream(w io.Writer, rec ORecord) error FromStream(data []byte) (ORecord, error) SetGlobalPropertyFunc(fnc GlobalPropertyFunc) }
RecordSerializer is an interface for serializing records to byte streams
func GetDefaultRecordSerializer ¶
func GetDefaultRecordSerializer() RecordSerializer
GetDefaultRecordSerializer returns default record serializer
func GetRecordFormat ¶
func GetRecordFormat(name string) RecordSerializer
GetRecordFormat returns record serializer by class name
type RecordType ¶
type RecordType byte
RecordType defines a registered record type
const ( RecordTypeDocument RecordType = 'd' RecordTypeBytes RecordType = 'b' RecordTypeFlat RecordType = 'f' )
List of standard record types
type Results ¶
type Results interface { Err() error Close() error Next(result interface{}) bool All(result interface{}) error }
Results is an interface for database command results. Must be closed.
Individual results can be iterated in a next way:
results := db.Command(cmd) if err := results.Err(); err != nil { // handle command errors; can be omitted and checked later with Err or Close } var one SomeStruct for results.Next(&one) { // process result, if any } if err := results.Close(); err != nil { // handle command and/or type conversion errors }
Or just retrieved all at once:
var arr []SomeStruct if err := results.All(&arr); err != nil { // handle command and/or type conversion errors }
Some commands may return just one int/bool value:
var affected int results.All(&affected)
Also results can be handled manually:
var out interface{} results.All(&out) switch out.(type) { case []OIdentifiable: // ... case *DocumentRecord: // ... }
type RidBag ¶
type RidBag struct {
// contains filtered or unexported fields
}
RidBag can have a tree-based or an embedded representation.
Embedded stores its content directly to the document that owns it. It is used when only small numbers of links are stored in the bag.
The tree-based implementation stores its content in a separate data structure called on OSBTreeBonsai on the server. It fits great for cases when you have a large number of links. This is used to efficiently manage relationships (particularly in graph databases).
The RidBag struct corresponds to ORidBag in Java client codebase.
type SQLCommand ¶
type SQLCommand struct {
// contains filtered or unexported fields
}
SQLCommand is a non-SELECT sql command (EXEC/INSERT/DELETE).
OCommandSQL in Java world.
func NewSQLCommand ¶
func NewSQLCommand(sql string, params ...interface{}) SQLCommand
NewSQLCommand creates a new SQL command request with given params.
Example:
NewSQLCommand("INSERT INTO People (id, name) VALUES (?, ?)", id, name)
func (SQLCommand) GetClassName ¶
func (rq SQLCommand) GetClassName() string
GetClassName returns Java class name
type SQLQuery ¶
type SQLQuery struct {
// contains filtered or unexported fields
}
SQLQuery is a SELECT-like SQL command.
OSQLQuery in Java world.
func NewSQLQuery ¶
NewSQLQuery creates a new SQL query with given params.
Example:
NewSQLQuery("SELECT FROM V WHERE id = ?", id)
func (SQLQuery) GetClassName ¶
GetClassName returns Java class name
type ScriptCommand ¶
type ScriptCommand struct {
// contains filtered or unexported fields
}
ScriptCommand is a way to execute batch-like commands.
OCommandScript in Java world.
func NewScriptCommand ¶
func NewScriptCommand(lang ScriptLang, body string, params ...interface{}) ScriptCommand
NewScriptCommand creates a new script request written in a given language (SQL/JS/Groovy/...), with specified body code and params.
Example:
NewScriptCommand(LangJS, `var out = db.command("SELECT FROM V"); out`)
func (ScriptCommand) GetClassName ¶
func (rq ScriptCommand) GetClassName() string
GetClassName returns Java class name
type ScriptLang ¶
type ScriptLang string
ScriptLang is a type for supported server-side script languages
type Serializable ¶
Serializable is an interface for objects that can be serialized to stream
type StorageType ¶
type StorageType string
StorageType defines supported database storage types
const ( // Persistent type represents on-disk database Persistent StorageType = "plocal" // Volatile type represents in-memory database Volatile StorageType = "memory" )
type StringRecordFormatAbs ¶
type StringRecordFormatAbs struct{}
func (StringRecordFormatAbs) FieldTypeFromStream ¶
func (f StringRecordFormatAbs) FieldTypeFromStream(tp OType, s string) interface{}
func (StringRecordFormatAbs) GetType ¶
func (StringRecordFormatAbs) GetType(s string) OType
type UnknownException ¶
UnknownException is an arbitrary exception from Java side. If exception class is not recognized by this driver, it will return UnknownException.
func (UnknownException) Error ¶
func (e UnknownException) Error() string
func (UnknownException) ExcClass ¶
func (e UnknownException) ExcClass() string
ExcClass returns Java exception class
func (UnknownException) ExcMessage ¶
func (e UnknownException) ExcMessage() string
ExcMessage returns exception message