Documentation ¶
Overview ¶
Package db is a generated protocol buffer package.
It is generated from these files:
models.proto
It has these top-level messages:
User Teammate Collection AuthToken Session Pageview
Index ¶
- Variables
- func AddTeammate(collection *Collection, user *User) error
- func CountUsers() (int, error)
- func DecodeSessionKey(key string) ([]byte, error)
- func DeleteAuthToken(id string) error
- func DeleteCollection(collection *Collection) error
- func DeleteCollectionShard(collection *Collection, shardID string) error
- func DeleteUser(user *User) error
- func EncodeSessionKey(k []byte) string
- func GetIDFromKey(key []byte) uint32
- func GetKey(t time.Time, id uint32) []byte
- func GetKeyFromTime(t time.Time) []byte
- func GetPVKey(sessionkey []byte, t time.Time) []byte
- func GetTimeFromKey(key []byte) time.Time
- func GetTimeFromPVKey(key []byte) time.Time
- func InitDatabase(basedirParam string)
- func InsertAuthToken(token *AuthToken) error
- func InsertCollection(collection *Collection) error
- func InsertUser(user *User) error
- func RemoveTeammate(collection *Collection, ID uint64) error
- func RunBackup(dir string) error
- func Seed(from time.Time, to time.Time, collectionID string, n int) error
- func ShardUpdate(collectionID string, fn func(tx *shardbolt.MultiTx) error) error
- func ShardUpsert(collectionID string, key []byte, v proto.Message) error
- func ShardUpsertBatch(collectionID string, key []byte, v proto.Message) error
- func ShardUpsertTx(tx *shardbolt.MultiTx, key []byte, v proto.Message) error
- func UpdateAuthToken(token *AuthToken) error
- func UpdateCollection(collection *Collection) error
- func UpdateUser(user *User) error
- func UserIsTeammate(collection *Collection, ID uint64) bool
- type AuthToken
- type Collection
- func (*Collection) Descriptor() ([]byte, []int)
- func (m *Collection) GetCreated() int64
- func (m *Collection) GetID() string
- func (m *Collection) GetName() string
- func (m *Collection) GetOwnerID() uint64
- func (m *Collection) GetTeammates() []*Teammate
- func (*Collection) ProtoMessage()
- func (m *Collection) Reset()
- func (m *Collection) String() string
- type CollectionDataInputT
- type CollectionDataT
- type CollectionStatDataT
- type CollectionSummary
- type CollectionSummaryOptions
- type ExtPageview
- type ExtSession
- type Pageview
- type PageviewDataT
- type Session
- func (*Session) Descriptor() ([]byte, []int)
- func (m *Session) GetASName() string
- func (m *Session) GetASNumber() int32
- func (m *Session) GetBrowserLanguage() string
- func (m *Session) GetBrowserName() string
- func (m *Session) GetBrowserVersion() string
- func (m *Session) GetCity() string
- func (m *Session) GetCountryCode() string
- func (m *Session) GetDeviceOS() string
- func (m *Session) GetDeviceType() string
- func (m *Session) GetDuration() int32
- func (m *Session) GetHostname() string
- func (m *Session) GetReferrer() string
- func (m *Session) GetScreenResolution() string
- func (m *Session) GetUserAgent() string
- func (m *Session) GetUserHostname() string
- func (m *Session) GetUserIP() string
- func (m *Session) GetWindowResolution() string
- func (*Session) ProtoMessage()
- func (m *Session) Reset()
- func (m *Session) String() string
- type SessionDataT
- type ShardDataT
- type Teammate
- type User
- func (*User) Descriptor() ([]byte, []int)
- func (m *User) GetCollectionLimit() uint32
- func (m *User) GetCreated() int64
- func (m *User) GetDisablePwChange() bool
- func (m *User) GetDisableUserDeletion() bool
- func (m *User) GetEmail() string
- func (m *User) GetEmailVerificationAt() int64
- func (m *User) GetEmailVerificationKey() string
- func (m *User) GetEmailVerified() bool
- func (m *User) GetID() uint64
- func (m *User) GetIsAdmin() bool
- func (m *User) GetLimitCollections() bool
- func (m *User) GetName() string
- func (m *User) GetPassword() string
- func (m *User) GetPasswordResetAt() int64
- func (m *User) GetPasswordResetKey() string
- func (*User) ProtoMessage()
- func (m *User) Reset()
- func (m *User) String() string
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyExists is an error what you can get if the key exists but it shouldn't ErrKeyExists = cipobolt.ErrKeyExists // ErrKeyNotExists is an error what you can get if the key not exists but it should ErrKeyNotExists = cipobolt.ErrKeyNotExists )
var ( BUser = []byte("User") BCollection = []byte("Collection") BSession = []byte("Session") BPageview = []byte("Pageview") BAuthToken = []byte("AuthToken") )
These are the bucket's names
Functions ¶
func AddTeammate ¶
func AddTeammate(collection *Collection, user *User) error
AddTeammate adds a Teammate to a user
func DecodeSessionKey ¶
DecodeSessionKey decodes a session key from base64
func DeleteCollection ¶
func DeleteCollection(collection *Collection) error
DeleteCollection deletes a collection
func DeleteCollectionShard ¶
func DeleteCollectionShard(collection *Collection, shardID string) error
DeleteCollectionShard deletes a shard from the collection
func EncodeSessionKey ¶
EncodeSessionKey encodes a session key with base64
func GetKeyFromTime ¶
GetKeyFromTime returns a database key based on time
func GetTimeFromKey ¶
GetTimeFromKey returns the time based on key
func GetTimeFromPVKey ¶
GetTimeFromPVKey return the time from the pageview key
func InitDatabase ¶
func InitDatabase(basedirParam string)
InitDatabase initializes the databases, creates the directories if necessary
func InsertAuthToken ¶
InsertAuthToken inserts an authtoken
func InsertCollection ¶
func InsertCollection(collection *Collection) error
InsertCollection inserts a new collection
func RemoveTeammate ¶
func RemoveTeammate(collection *Collection, ID uint64) error
RemoveTeammate removes a teammate by email
func ShardUpdate ¶
ShardUpdate runs the fn in a shard
func ShardUpsert ¶
ShardUpsert upsert a value into shards
func ShardUpsertBatch ¶
ShardUpsertBatch upsert a value into shards, but not in a separated transaction
func ShardUpsertTx ¶
ShardUpsertTx upsert a value into shards in a transaction
func UpdateAuthToken ¶
UpdateAuthToken updates an authtoken
func UpdateCollection ¶
func UpdateCollection(collection *Collection) error
UpdateCollection updates a new collection
func UserIsTeammate ¶
func UserIsTeammate(collection *Collection, ID uint64) bool
UserIsTeammate check whether the User inside the collection's team
Types ¶
type AuthToken ¶
type AuthToken struct { ID string `protobuf:"bytes,1,opt,name=ID,json=iD" json:"ID,omitempty"` OwnerID uint64 `protobuf:"varint,2,opt,name=OwnerID,json=ownerID" json:"OwnerID,omitempty"` TTL int32 `protobuf:"varint,3,opt,name=TTL,json=tTL" json:"TTL,omitempty"` Created int64 `protobuf:"varint,4,opt,name=Created,json=created" json:"Created,omitempty"` }
func GetAuthToken ¶
GetAuthToken returns an authtoken with the id parameter
func (*AuthToken) Descriptor ¶
func (*AuthToken) GetCreated ¶
func (*AuthToken) GetOwnerID ¶
func (*AuthToken) ProtoMessage ¶
func (*AuthToken) ProtoMessage()
type Collection ¶
type Collection struct { ID string `protobuf:"bytes,1,opt,name=ID,json=iD" json:"ID,omitempty"` OwnerID uint64 `protobuf:"varint,2,opt,name=OwnerID,json=ownerID" json:"OwnerID,omitempty"` Name string `protobuf:"bytes,3,opt,name=Name,json=name" json:"Name,omitempty"` Teammates []*Teammate `protobuf:"bytes,4,rep,name=Teammates,json=teammates" json:"Teammates,omitempty"` Created int64 `protobuf:"varint,5,opt,name=Created,json=created" json:"Created,omitempty"` }
func GetCollection ¶
func GetCollection(id string) (*Collection, error)
GetCollection returns a collection with the id parameter
func GetCollectionByName ¶
func GetCollectionByName(ownerID uint64, name string) (*Collection, error)
GetCollectionByName returns a collection
func GetCollections ¶
func GetCollections() ([]Collection, error)
GetCollections returns all the collections
func GetCollectionsByUserID ¶
func GetCollectionsByUserID(ID uint64) ([]Collection, error)
GetCollectionsByUserID returns collections accessible by the user
func GetCollectionsOwnedByUser ¶
func GetCollectionsOwnedByUser(ID uint64) ([]Collection, error)
GetCollectionsOwnedByUser returns the collections owned by user
func (*Collection) Descriptor ¶
func (*Collection) Descriptor() ([]byte, []int)
func (*Collection) GetCreated ¶
func (m *Collection) GetCreated() int64
func (*Collection) GetID ¶
func (m *Collection) GetID() string
func (*Collection) GetName ¶
func (m *Collection) GetName() string
func (*Collection) GetOwnerID ¶
func (m *Collection) GetOwnerID() uint64
func (*Collection) GetTeammates ¶
func (m *Collection) GetTeammates() []*Teammate
func (*Collection) ProtoMessage ¶
func (*Collection) ProtoMessage()
func (*Collection) Reset ¶
func (m *Collection) Reset()
func (*Collection) String ¶
func (m *Collection) String() string
type CollectionDataInputT ¶
type CollectionDataInputT struct { From time.Time To time.Time Bucket string Timezone string Filter map[string]string }
CollectionDataInputT is the input filter struct for the clients
type CollectionDataT ¶
type CollectionDataT struct { ID string `json:"id"` Name string `json:"name"` OwnerName string `json:"owner_name"` SessionSums []*bucketSumT `json:"session_sums"` PageviewSums []*bucketSumT `json:"pageview_sums"` }
CollectionDataT is the collection's data struct for the clients
func GetBucketSums ¶
func GetBucketSums(collection *Collection, input *CollectionDataInputT) (*CollectionDataT, error)
GetBucketSums returns the bucket by hour or day or week or month
type CollectionStatDataT ¶
type CollectionStatDataT struct { SessionTotal totalT `json:"session_total"` PageviewTotal totalT `json:"pageview_total"` AvgSessionLength totalT `json:"avg_session_length"` BounceRate percentT `json:"bounce_rate"` PageSums []sumT `json:"page_sums"` QueryStringSums []sumT `json:"query_string_sums"` HostnameSums []sumT `json:"hostname_sums"` DeviceTypeSums []sumT `json:"device_type_sums"` DeviceOSSums []sumT `json:"device_os_sums"` BrowserNameSums []sumT `json:"browser_name_sums"` BrowserVersionSums []sumT `json:"browser_version_sums"` BrowserLanguageSums []sumT `json:"browser_language_sums"` PageviewCountSums []sumT `json:"pageview_count_sums"` ScreenResolutionSums []sumT `json:"screen_resolution_sums"` WindowResolutionSums []sumT `json:"window_resolution_sums"` CountryCodeSums []sumT `json:"country_code_sums"` CitySums []sumT `json:"city_sums"` ASNameSums []sumT `json:"as_name_sums"` ReferrerSums []sumT `json:"referrer_sums"` }
CollectionStatDataT is the collection's statistic data struct for the clients
func GetStatistics ¶
func GetStatistics(collection *Collection, input *CollectionDataInputT) (*CollectionStatDataT, error)
GetStatistics returns the statistic data for the collection
type CollectionSummary ¶
type CollectionSummary struct { SessionCount int `json:"session_count"` SessionPercent float32 `json:"session_percent"` SessionSums []*bucketSumT `json:"session_sums"` PageviewCount int `json:"pageview_count"` PageviewPercent float32 `json:"pageview_percent"` PageviewSums []*bucketSumT `json:"pageview_sums"` }
CollectionSummary contains summary for the collection
func GetCollectionSummary ¶
func GetCollectionSummary(collectionID string, dayBefore int, options CollectionSummaryOptions) (CollectionSummary, error)
GetCollectionSummary returns the last daybefore days versus the previous daybefore days summary
type CollectionSummaryOptions ¶
type CollectionSummaryOptions struct {
Timezone string `json:"timezone"`
}
CollectionSummaryOptions contains the options for the GetColectionSummary function
type ExtPageview ¶
ExtPageview extends the Pageview proto struct with calculated information
type ExtSession ¶
ExtSession extends the Session proto struct with calculated information
type Pageview ¶
type Pageview struct { Path string `protobuf:"bytes,1,opt,name=Path,json=path" json:"Path,omitempty"` QueryString string `protobuf:"bytes,2,opt,name=QueryString,json=queryString" json:"QueryString,omitempty"` }
func (*Pageview) Descriptor ¶
func (*Pageview) GetQueryString ¶
func (*Pageview) ProtoMessage ¶
func (*Pageview) ProtoMessage()
type PageviewDataT ¶
type PageviewDataT struct { Time int64 `json:"time"` Path string `json:"path"` QueryString string `json:"query_string"` }
PageviewDataT is the pageview data struct for the clients
func GetPageviews ¶
func GetPageviews(collection *Collection, sessionKey []byte) ([]*PageviewDataT, error)
GetPageviews returns the session's pageviews
type Session ¶
type Session struct { Duration int32 `protobuf:"varint,1,opt,name=Duration,json=duration" json:"Duration,omitempty"` Hostname string `protobuf:"bytes,2,opt,name=Hostname,json=hostname" json:"Hostname,omitempty"` DeviceOS string `protobuf:"bytes,3,opt,name=DeviceOS,json=deviceOS" json:"DeviceOS,omitempty"` BrowserName string `protobuf:"bytes,4,opt,name=BrowserName,json=browserName" json:"BrowserName,omitempty"` BrowserVersion string `protobuf:"bytes,5,opt,name=BrowserVersion,json=browserVersion" json:"BrowserVersion,omitempty"` BrowserLanguage string `protobuf:"bytes,6,opt,name=BrowserLanguage,json=browserLanguage" json:"BrowserLanguage,omitempty"` ScreenResolution string `protobuf:"bytes,7,opt,name=ScreenResolution,json=screenResolution" json:"ScreenResolution,omitempty"` WindowResolution string `protobuf:"bytes,8,opt,name=WindowResolution,json=windowResolution" json:"WindowResolution,omitempty"` DeviceType string `protobuf:"bytes,9,opt,name=DeviceType,json=deviceType" json:"DeviceType,omitempty"` CountryCode string `protobuf:"bytes,10,opt,name=CountryCode,json=countryCode" json:"CountryCode,omitempty"` City string `protobuf:"bytes,11,opt,name=City,json=city" json:"City,omitempty"` UserAgent string `protobuf:"bytes,12,opt,name=UserAgent,json=userAgent" json:"UserAgent,omitempty"` UserIP string `protobuf:"bytes,13,opt,name=UserIP,json=userIP" json:"UserIP,omitempty"` UserHostname string `protobuf:"bytes,14,opt,name=UserHostname,json=userHostname" json:"UserHostname,omitempty"` Referrer string `protobuf:"bytes,15,opt,name=Referrer,json=referrer" json:"Referrer,omitempty"` ASNumber int32 `protobuf:"varint,16,opt,name=ASNumber,json=aSNumber" json:"ASNumber,omitempty"` ASName string `protobuf:"bytes,17,opt,name=ASName,json=aSName" json:"ASName,omitempty"` }
func GetSession ¶
GetSession returns a session
func (*Session) Descriptor ¶
func (*Session) GetASNumber ¶
func (*Session) GetBrowserLanguage ¶
func (*Session) GetBrowserName ¶
func (*Session) GetBrowserVersion ¶
func (*Session) GetCountryCode ¶
func (*Session) GetDeviceOS ¶
func (*Session) GetDeviceType ¶
func (*Session) GetDuration ¶
func (*Session) GetHostname ¶
func (*Session) GetReferrer ¶
func (*Session) GetScreenResolution ¶
func (*Session) GetUserAgent ¶
func (*Session) GetUserHostname ¶
func (*Session) GetWindowResolution ¶
func (*Session) ProtoMessage ¶
func (*Session) ProtoMessage()
type SessionDataT ¶
type SessionDataT struct { Key string `json:"key"` Hostname string `json:"hostname"` DeviceOS string `json:"device_os"` BrowserName string `json:"browser_name"` BrowserVersion string `json:"browser_version"` BrowserLanguage string `json:"browser_language"` ScreenResolution string `json:"screen_resolution"` WindowResolution string `json:"window_resolution"` DeviceType string `json:"device_type"` CountryCode string `json:"country_code"` City string `json:"city"` ASNumber int32 `json:"as_number"` ASName string `json:"as_name"` UserAgent string `json:"user_agent"` UserIP string `json:"user_ip"` UserHostname string `json:"user_hostname"` Begin int64 `json:"begin"` Duration int32 `json:"duration"` PageviewCount int `json:"pageview_count"` Referrer string `json:"referrer"` }
SessionDataT is the session data struct for the clients
func GetSessions ¶
func GetSessions(collection *Collection, input *CollectionDataInputT) ([]*SessionDataT, error)
GetSessions returns the collection's sessions
type ShardDataT ¶
ShardDataT is the shard data struct for the clients
func GetCollectionShardDatas ¶
func GetCollectionShardDatas(collection *Collection) ([]ShardDataT, error)
GetCollectionShardDatas returns the collection's shards information
type Teammate ¶
type Teammate struct {
ID uint64 `protobuf:"varint,1,opt,name=ID,json=iD" json:"ID,omitempty"`
}
func GetTeammate ¶
func GetTeammate(collection *Collection, ID uint64) *Teammate
GetTeammate returns the teammate by ID
func (*Teammate) Descriptor ¶
func (*Teammate) ProtoMessage ¶
func (*Teammate) ProtoMessage()
type User ¶
type User struct { ID uint64 `protobuf:"varint,1,opt,name=ID,json=iD" json:"ID,omitempty"` Email string `protobuf:"bytes,2,opt,name=Email,json=email" json:"Email,omitempty"` Password string `protobuf:"bytes,3,opt,name=Password,json=password" json:"Password,omitempty"` Created int64 `protobuf:"varint,4,opt,name=Created,json=created" json:"Created,omitempty"` Name string `protobuf:"bytes,5,opt,name=Name,json=name" json:"Name,omitempty"` IsAdmin bool `protobuf:"varint,10,opt,name=IsAdmin,json=isAdmin" json:"IsAdmin,omitempty"` DisablePwChange bool `protobuf:"varint,11,opt,name=DisablePwChange,json=disablePwChange" json:"DisablePwChange,omitempty"` LimitCollections bool `protobuf:"varint,12,opt,name=LimitCollections,json=limitCollections" json:"LimitCollections,omitempty"` CollectionLimit uint32 `protobuf:"varint,13,opt,name=CollectionLimit,json=collectionLimit" json:"CollectionLimit,omitempty"` DisableUserDeletion bool `protobuf:"varint,14,opt,name=DisableUserDeletion,json=disableUserDeletion" json:"DisableUserDeletion,omitempty"` EmailVerified bool `protobuf:"varint,20,opt,name=EmailVerified,json=emailVerified" json:"EmailVerified,omitempty"` EmailVerificationKey string `protobuf:"bytes,21,opt,name=EmailVerificationKey,json=emailVerificationKey" json:"EmailVerificationKey,omitempty"` EmailVerificationAt int64 `protobuf:"varint,22,opt,name=EmailVerificationAt,json=emailVerificationAt" json:"EmailVerificationAt,omitempty"` PasswordResetKey string `protobuf:"bytes,23,opt,name=PasswordResetKey,json=passwordResetKey" json:"PasswordResetKey,omitempty"` PasswordResetAt int64 `protobuf:"varint,24,opt,name=PasswordResetAt,json=passwordResetAt" json:"PasswordResetAt,omitempty"` }
func GetUserByEmail ¶
GetUserByEmail returns an user with the email parameter
func GetUserByID ¶
GetUserByID returns an user with the email parameter
func GetUserByName ¶
GetUserByName returns an user with the name parameter
func (*User) Descriptor ¶
func (*User) GetCollectionLimit ¶
func (*User) GetCreated ¶
func (*User) GetDisablePwChange ¶
func (*User) GetDisableUserDeletion ¶
func (*User) GetEmailVerificationAt ¶
func (*User) GetEmailVerificationKey ¶
func (*User) GetEmailVerified ¶
func (*User) GetIsAdmin ¶
func (*User) GetLimitCollections ¶
func (*User) GetPassword ¶
func (*User) GetPasswordResetAt ¶
func (*User) GetPasswordResetKey ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()