Documentation
¶
Index ¶
- Constants
- Variables
- func AutoBlock(dbPath string, m Model, method BlockMethod, n int64) string
- func ID(m Model) string
- func Indexes(m Model) map[string]interface{}
- func ParseID(id string) (dataset string, block string, record string, err error)
- func SetLogLevel(l LogLevel)
- func SetLogger(l *golog.Logger)
- type BlockMethod
- type Config
- type Error
- type GitDb
- type LockableModel
- type LogLevel
- type Model
- type ResolvableError
- type Schema
- type SearchMode
- type SearchParam
- type TimeStampedModel
- type Transaction
- type Upload
- type UploadModel
- type User
Constants ¶
const RecVersion = "v2"
RecVersion of gitdb
Variables ¶
var ( ErrNoRecords = errors.ErrNoRecords ErrRecordNotFound = errors.ErrRecordNotFound ErrInvalidRecordID = errors.ErrInvalidRecordID ErrDBSyncFailed = errors.ErrDBSyncFailed ErrLowBattery = errors.ErrLowBattery ErrNoOnlineRemote = errors.ErrNoOnlineRemote ErrAccessDenied = errors.ErrAccessDenied ErrInvalidDataset = errors.ErrInvalidDataset )
Functions ¶
func AutoBlock ¶
func AutoBlock(dbPath string, m Model, method BlockMethod, n int64) string
AutoBlock automatically generates block id for a given Model depending on a BlockMethod
Types ¶
type BlockMethod ¶
type BlockMethod string
BlockMethod type of method to use with AutoBlock
var ( //BlockBySize generates a new block when current block has reached a specified size BlockBySize BlockMethod = "size" //BlockByCount generates a new block when the number of records has reached a specified count BlockByCount BlockMethod = "count" )
type Config ¶
type Config struct {
ConnectionName string
DBPath string
OnlineRemote string
EncryptionKey string
SyncInterval time.Duration
User *User
Factory func(string) Model
EnableUI bool
UIPort int
// Mock is a hook for testing apps. If true will return a Mock DB connection
Mock bool
Driver dbDriver
}
Config represents configuration options for GitDB
func NewConfigWithLocalDriver ¶
NewConfigWithLocalDriver constructs a *Config
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func ErrorWithResolution ¶
func (Error) Resolution ¶
type GitDb ¶
type GitDb interface {
Close() error
Insert(m Model) error
InsertMany(m []Model) error
Get(id string, m Model) error
Exists(id string) error
Fetch(dataset string, block ...string) ([]*db.Record, error)
Search(dataDir string, searchParams []*SearchParam, searchMode SearchMode) ([]*db.Record, error)
Delete(id string) error
DeleteOrFail(id string) error
Lock(m Model) error
Unlock(m Model) error
Upload() *Upload
Migrate(from Model, to Model) error
GetMails() []*mail
StartTransaction(name string) Transaction
GetLastCommitTime() (time.Time, error)
SetUser(user *User) error
Config() Config
Sync() error
RegisterModel(dataset string, m Model) bool
}
GitDb interface defines all exported funcs an implementation must have
type LockableModel ¶
type LockableModel interface {
//GetLockFileNames informs GitDb of files a Models using for locking
GetLockFileNames() []string
}
type Model ¶
type Model interface {
GetSchema() *Schema
//Validate validates a Model
Validate() error
//ShouldEncrypt informs GitDb if a Model support encryption
ShouldEncrypt() bool
//BeforeInsert is called by gitdb before insert
BeforeInsert() error
}
Model interface describes methods GitDB supports
type ResolvableError ¶
type ResolvableError interface {
Resolution() string
}
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema holds functions for generating a model id
type SearchMode ¶
type SearchMode int
SearchMode defines how gitdb should search with SearchParam
const ( // SearchEquals will search index for records whose values equal SearchParam.Value SearchEquals SearchMode = 1 // SearchContains will search index for records whose values contain SearchParam.Value SearchContains SearchMode = 2 // SearchStartsWith will search index for records whose values start with SearchParam.Value SearchStartsWith SearchMode = 3 // SearchEndsWith will search index for records whose values ends with SearchParam.Value SearchEndsWith SearchMode = 4 )
type SearchParam ¶
SearchParam represents search parameters against GitDB index
type TimeStampedModel ¶
TimeStampedModel provides time stamp fields
func (*TimeStampedModel) BeforeInsert ¶
func (m *TimeStampedModel) BeforeInsert() error
BeforeInsert implements Model.BeforeInsert
type Transaction ¶
type Transaction interface {
Commit() error
AddOperation(o operation)
}
Transaction represents a db transaction
type Upload ¶
type Upload struct {
// contains filtered or unexported fields
}
Upload provides API for managing file uploads
func (*Upload) Get ¶
func (u *Upload) Get(id string, result *UploadModel) error
Get returns an upload by id
type UploadModel ¶
type UploadModel struct {
Bucket string
File string
Path string
UploadedBy string
TimeStampedModel
}
UploadModel represents a file upload
func (*UploadModel) GetSchema ¶
func (u *UploadModel) GetSchema() *Schema
GetSchema implements Model.GetSchema
func (*UploadModel) ShouldEncrypt ¶
func (U *UploadModel) ShouldEncrypt() bool
func (*UploadModel) Validate ¶
func (u *UploadModel) Validate() error
Validate implements Model.Validate
type User ¶
User represents the user currently connected to the database and will be used to identify who made changes to it
func (*User) AuthorName ¶
AuthorName return commit author git style