Documentation ¶
Index ¶
- Constants
- func AutoBlock(dbPath string, m Model, method BlockMethod, n int64) func() string
- func ID(m Model) string
- func Indexes(m Model) map[string]interface{}
- func ParseID(id string) (dataDir string, block string, record string, err error)
- func SetLogLevel(l LogLevel)
- func SetLogger(l *golog.Logger)
- type BlockMethod
- type Config
- type DbUser
- type GitDb
- type IndexFunc
- type LogLevel
- type Model
- type Schema
- type SearchMode
- type SearchParam
- type StringFunc
- type TimeStampedModel
Constants ¶
const RecVersion = "v2"
RecVersion of gitdb
Variables ¶
This section is empty.
Functions ¶
func AutoBlock ¶
func AutoBlock(dbPath string, m Model, method BlockMethod, n int64) func() 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 GitDriver dbDriver User *DbUser Factory func(string) Model }
Config represents configuration options for GitDB
type DbUser ¶
DbUser represents the user currently connected to the database and will be used to identify who made changes to it
func (*DbUser) AuthorName ¶
AuthorName return commit author git style
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) ([]*record, error) Search(dataDir string, searchParams []*SearchParam, searchMode SearchMode) ([]*record, error) Delete(id string) error DeleteOrFail(id string) error Lock(m Model) error Unlock(m Model) error Migrate(from Model, to Model) error GetMails() []*mail StartTransaction(name string) *transaction GetLastCommitTime() (time.Time, error) SetUser(user *DbUser) error }
GitDb interface defines all export funcs an implementation must have
type IndexFunc ¶
type IndexFunc func() map[string]interface{}
IndexFunc is a function that returns a map of indexes keyed by field name
type LogLevel ¶
type LogLevel int
LogLevel is used to set verbosity of GitDB
const ( //LogLevelNone - log nothing LogLevelNone LogLevel = 0 //LogLevelError - logs only errors LogLevelError LogLevel = 1 //LogLevelWarning - logs warning and errors LogLevelWarning LogLevel = 2 //LogLevelTest - logs only debug messages LogLevelTest LogLevel = 3 //LogLevelInfo - logs info, warining and errors LogLevelInfo LogLevel = 4 )
type Model ¶
type Model interface { GetSchema() *Schema //Validate validates a Model Validate() error //IsLockable informs GitDb if a Model support locking IsLockable() bool //GetLockFileNames informs GitDb of files a Models using for locking GetLockFileNames() []string //ShouldEncrypt informs GitDb if a Model support encryption ShouldEncrypt() bool //SetBaseModel sets shared fields and is called by gitdb before insert SetBaseModel() }
Model interface describes methods GitDB supports
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema interface for all schema structs
func NewSchema ¶
func NewSchema(name, block, record StringFunc, indexes IndexFunc) *Schema
NewSchema constructs a *Schema
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 StringFunc ¶
type StringFunc func() string
StringFunc is a function that takes no argument and returns a string
type TimeStampedModel ¶
TimeStampedModel provides time stamp fields
func (*TimeStampedModel) SetBaseModel ¶
func (m *TimeStampedModel) SetBaseModel()
SetBaseModel sets shared fields and is called by gitdb before insert