Documentation ¶
Index ¶
- Constants
- Variables
- func NewErrDatabaseExist(name string) error
- func NewErrDatabaseNotExist(name string) error
- func NewErrDatabaseOptionsInvalid(opts any) error
- func NewErrObjectNotExist(key Key) error
- func NewErrSchemaNotExist(name string) error
- type Collection
- type Database
- type DatabaseOperation
- type DatabaseOptions
- type DocumentOperation
- type IndexOperation
- type Key
- type LimitOption
- type Object
- type OffsetOption
- type Option
- type Order
- type OrderOption
- type ResultSet
- type Schema
- type Store
- type StoreOperation
- type Transaction
- type TransactionOperation
- type TransactionOption
Constants ¶
const ( OrderNone = Order(0) OrderAsc = Order(1) OrderDesc = Order(2) )
Order options.
Variables ¶
var ( ErrNotExist = errors.New("not exist") ErrExist = errors.New("exist") ErrInvalid = errors.New("invalid") )
var NoLimit = int(0)
NoLimit represents a no limit option.
var NoOffset = uint(0)
NoOffset represents a no offset option.
Functions ¶
func NewErrDatabaseExist ¶ added in v1.3.0
func NewErrDatabaseNotExist ¶ added in v1.3.0
func NewErrDatabaseOptionsInvalid ¶ added in v1.3.0
func NewErrObjectNotExist ¶ added in v1.3.0
func NewErrSchemaNotExist ¶ added in v1.3.0
Types ¶
type Collection ¶ added in v0.9.0
type Collection = document.Collection
type Database ¶
type Database interface { // Name returns the unique name. Name() string // Options returns the database options. Options() DatabaseOptions // Transact begin a new transaction. Transact(write bool) (Transaction, error) }
Database represents a database interface.
type DatabaseOperation ¶
type DatabaseOperation interface { // CreateCollection creates a new collection. CreateCollection(ctx context.Context, col Collection) error // UpdateCollection updates the specified collection. UpdateCollection(ctx context.Context, col Collection) error // GetCollection returns the specified collection. GetCollection(ctx context.Context, name string) (Collection, error) // RemoveCollection removes the specified collection. RemoveCollection(ctx context.Context, name string) error // TruncateCollections removes all collections. TruncateCollections(ctx context.Context) error }
DatabaseOperation represents a database operation.
type DatabaseOptions ¶ added in v0.9.0
type DatabaseOptions = map[string]interface{}
DatabaseOptions represents a database options.
type DocumentOperation ¶
type DocumentOperation interface { // InsertDocument puts a document object with the specified primary key. InsertDocument(ctx context.Context, docKey Key, obj Object) error // FindDocuments returns a result set matching the specified key. FindDocuments(ctx context.Context, docKey Key, opts ...Option) (ResultSet, error) // UpdateDocument updates a document object with the specified primary key. UpdateDocument(ctx context.Context, docKey Key, obj Object) error // RemoveDocument removes a document object with the specified primary key. RemoveDocument(ctx context.Context, docKey Key) error // RemoveDocuments removes document objects with the specified primary key. RemoveDocuments(ctx context.Context, docKey Key) error // TruncateDocuments removes all document objects. TruncateDocuments(ctx context.Context) error }
DocumentOperation represents a document operation.
type IndexOperation ¶
type IndexOperation interface { // InsertIndex puts a secondary index with the primary key. InsertIndex(ctx context.Context, idxKey Key, key Key) error // RemoveIndex removes the specified secondary index. RemoveIndex(ctx context.Context, idxKey Key) error // FindDocumentsByIndex returns a result set matching the specified index key. FindDocumentsByIndex(ctx context.Context, indexKey Key, opts ...Option) (ResultSet, error) // TruncateIndexes removes all secondary indexes. TruncateIndexes(ctx context.Context) error }
IndexOperation represents a secondary index operation.
type LimitOption ¶ added in v1.0.0
type LimitOption struct {
Limit int
}
LimitOption represents a limit option.
func NewLimitOptionWith ¶ added in v1.0.0
func NewLimitOptionWith(limit int) *LimitOption
NewLimitOptionWith returns a new limit option.
type OffsetOption ¶ added in v1.0.0
type OffsetOption struct {
Offset uint
}
OffsetOption represents an offset option.
func NewOffsetOption ¶ added in v1.0.0
func NewOffsetOption(offset uint) *OffsetOption
NewLimitOption returns a new offset option.
type OrderOption ¶ added in v1.0.0
type OrderOption struct {
Order Order
}
OrderOption represents a order option.
func NewOrderOptionWith ¶ added in v1.0.0
func NewOrderOptionWith(order Order) *OrderOption
NewOrderOptionWith returns a new order option.
type ResultSet ¶
type ResultSet interface { // Next moves the cursor forward next object from its current position. Next() bool // Object returns an object in the current position. Object() Object // Object returns all objects in the result set. Objects() []Object }
ResultSet represents a result set which includes query execution results.
type Store ¶
type Store interface { // SetDocumentCoder sets the document coder. SetDocumentCoder(coder document.Coder) // SetKeyCoder sets the key coder. SetKeyCoder(coder document.KeyCoder) // CreateDatabase creates a new database. CreateDatabase(ctx context.Context, name string) error // GetDatabase retruns the specified database. GetDatabase(ctx context.Context, name string) (Database, error) // RemoveDatabase removes the specified database. RemoveDatabase(ctx context.Context, name string) error // ListDatabases returns the all databases. ListDatabases(ctx context.Context) ([]Database, error) }
Store represents a store interface.
type StoreOperation ¶ added in v1.1.0
type StoreOperation interface { DatabaseOperation DocumentOperation IndexOperation }
StoreOperation represents a transaction operation.
type Transaction ¶
type Transaction interface { TransactionOperation StoreOperation // Database returns the transaction database. Database() Database }
Transaction represents a transaction interface.
type TransactionOperation ¶
type TransactionOperation interface { TransactionOption // Commit commits this transaction. Commit(ctx context.Context) error // Cancel cancels this transaction. Cancel(ctx context.Context) error }
TransactionOperation represents a transaction operation.
type TransactionOption ¶ added in v1.1.0
type TransactionOption interface { // SetAutoCommit sets the auto commit flag. SetAutoCommit(bool) // IsAutoCommit returns true whether the auto commit flag is set. IsAutoCommit() bool // SetTimeout sets the timeout of this transaction. SetTimeout(t time.Duration) error }
TransactionOption represents a transaction option.