Categorygithub.com/roomful/orientgo
modulepackage
0.0.0-20181105131850-02f036d2a296
Repository: https://github.com/roomful/orientgo.git
Documentation: pkg.go.dev

# README

Overview

Build Status GoDoc

OrientGo is a Go client for the OrientDB database.

OrientGo Logo

Status

OrientDB versions supported: 2.0.15 - 2.1.5

Not supported versions:

  • 2.1.0 (bug in OrientDB, see #28)
  • 2.1.3 (broken protocol, see #39)

Driver is no longer maintained and seeking for a new owner.

Ogonori

Original ogonori API is deprecated. Still, it's source code have been frozen in v1.0 branch. To use it, simply replace github.com/quux00/ogonori imports with gopkg.in/istreamdata/orientgo.v1.

Supported features:

  • Mostly any SQL queries, commands and batch requests.
  • Server-side scripts (via ScriptCommand or functions).
  • Command results conversion to custom types via mapstructure.
  • Direct CRUD operations on Document or BytesRecord objects.
  • Management of databases and record clusters.
  • Can be used for the golang database/sql API, with some cautions (see below).
  • Only supports OrientDB 2.x series.

Not supported yet:

  • OrientDB 1.x.
  • Servers with cluster configuration (not tested).
  • Fetch plans are temporary disabled due to internal changes.
  • Transactions in Go. Transactions in JS can be used instead.
  • Live queries.
  • Command results streaming (#26).
  • OrientDB CUSTOM type.
  • ORM-like API. See Issue #6.

Caveat on using OrientGo as a database/sql API driver

WARNING: database/sql API is disabled for now.

The golang database/sql API has some constraints that can be make it painful to work with OrientDB. For example:

  • When you insert a record, the Go database/sql API only allows one to return a single int64 identifier for the record, but OrientDB uses as a compound int16:int64 RID, so getting the RID of records you just inserted requires another round trip to the database to query the RID.

Also, since OrientDB transactions are not supported, the Tx portion of the database/sql API is not yet implemented.

Development

You are welcome to initiate pull request and suggest a more user-friendly API. We will try to review them ASAP.

How to run functional tests:

  1. Install Docker

  2. Pull OrientDB image: docker pull dennwc/orientdb:2.1

  3. go test -v ./...

Examples

Dial example - dial_example_test.go

LICENSE

The MIT License

# Packages

No description provided by the author

# Functions

Dial opens a new connection to OrientDB server.
GetDefaultRecordSerializer returns default record serializer.
GetRecordFactory returns RecordFactory for a given type.
GetRecordFormat returns record serializer by class name.
MarshalContent is a helper for constructing SQL commands with CONTENT keyword.
MustParseRID is a version of ParseRID which panics on errors.
No description provided by the author
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.
NewDocumentFromRID creates new empty document with given RID.
NewEmptyDocument creates new empty document.
NewEmptyRID returns an RID with the default "invalid" settings.
NewFunctionCommand creates a new call request to server-side function with given name and arguments.
based on how the Java client does it ; TODO: document usage.
Should be passed an Document that comes from a load schema request to the database.
NewOPropertyFromDocument creates a new OProperty from an Document that was created after a load schema call to the OrientDB server.
NewRecordOfType creates a new record of specified type.
NewRID creates a RID with given ClusterId and ClusterPos.
No description provided by the author
NewRIDInCluster creates an empty RID inside specified cluster.
NewScriptCommand creates a new script request written in a given language (SQL/JS/Groovy/...), with specified body code and params.
NewSQLCommand creates a new SQL command request with given params.
NewSQLQuery creates a new SQL query with given params.
No description provided by the author
No description provided by the author
ParseRID converts a string of form #N:M or N:M to a RID.
RegException registers a function to convert server exception based on it's class.
RegisterMapDecoderHook allows to register additional hook for map decoder.
RegisterProto registers a new protocol for Dial command.
RegisterRecordFormat registers RecordSerializer with a given class name.
SerializeAnyStreamable serializes a given object.
SetDefaultRecordFormat sets default record serializer.
SetRetryCountConcurrent sets a retry count when ErrConcurrentModification occurs.

# Constants

in alignment with: http://orientdb.com/docs/last/Types.html.
means []byte.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
DefaultFetchPlan is an empty fetch plan.
List of database access types.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
FollowAll is a fetch plan that follows all links.
List of database access types.
in alignment with: http://orientdb.com/docs/last/Types.html.
List of supported server-side script languages.
List of supported server-side script languages.
List of supported server-side script languages.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
NoFollow is a fetch plan that does not follow any links.
Persistent type represents on-disk database.
Default protocols.
List of standard record types.
List of standard record types.
List of standard record types.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
in alignment with: http://orientdb.com/docs/last/Types.html.
driver addition.
Volatile type represents in-memory database.

# Variables

ErrNoRecord is returned when trying to deserialize an empty result set into a single value.
MaxConnections limits the number of opened connections.
TagName is a name for a struct tag used for types conversion using reflect.

# Structs

Admin wraps a database management session.
No description provided by the author
BytesRecord is a rawest representation of a record.
Client represents connection to OrientDB server.
Database wraps a database session.
No description provided by the author
DocEntry is a generic data holder that goes in Documents.
No description provided by the author
No description provided by the author
ErrInvalidConn is returned than DB functions are called without active DB connection.
ErrMultipleRecords is returned when trying to deserialize a result set with multiple records into a single value.
ErrTypeSerialization represent serialization/deserialization error.
No description provided by the author
Function is a server-side function description.
FunctionCommand is a command to call server-side function.
No description provided by the author
ODatabase stores database metadata.
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.
OProperty roughly corresponds to OProperty in the Java client.
OServerException encapsulates Java-based Exceptions from the OrientDB server.
RID encapsulates the two aspects of an OrientDB RecordID - ClusterID:ClusterPos.
RidBag can have a tree-based or an embedded representation.
ScriptCommand is a way to execute batch-like commands.
SQLCommand is a non-SELECT sql command (EXEC/INSERT/DELETE).
SQLQuery is a SELECT-like SQL command.
No description provided by the author
UnknownException is an arbitrary exception from Java side.

# Interfaces

Classer is an interface for object that have analogs in OrientDB Java code.
CustomSerializable is an interface for objects that can be sent on wire.
DBAdmin is a minimal interface for database management API implementation.
DBConnection is a minimal interface for OrientDB server API implementation.
DBSession is a minimal interface for database API implementation.
Deserializable is an interface for objects that can be deserialized from stream.
DocumentDeserializable is an interface for objects that can be filled from Document.
DocumentSerializable is an interface for objects that can be converted to Document.
Exception is an interface for Java-based Exceptions.
MapSerializable is an interface for objects that can be converted to map[string]interface{}.
OCommandRequestText is an interface for text-based database commands, which can be executed using database.Command function.
No description provided by the author
No description provided by the author
No description provided by the author
RecordSerializer is an interface for serializing records to byte streams.
Results is an interface for database command results.
Serializable is an interface for objects that can be serialized to stream.

# Type aliases

DatabaseType defines database access type (Document or Graph).
FetchPlan is an additional parameter to queries, that instructs DB how to handle linked documents.
GlobalPropertyFunc is a function for getting global properties by id.
OType is an enum for the various data types supported by OrientDB.
RecordFactory is a function to create records of certain type.
RecordType defines a registered record type.
ScriptLang is a type for supported server-side script languages.
StorageType defines supported database storage types.