skydb

package
v1.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 5, 2019 License: Apache-2.0 Imports: 19 Imported by: 91

Documentation

Index

Constants

View Source
const (
	Ascending SortOrder = iota
	Descending
	Asc  = Ascending
	Desc = Descending
)

A list of SordOrder, their meaning is self descriptive.

View Source
const WildcardRecordField = "*"

WildcardRecordField is a special record field that applies to all record fields

View Source
const WildcardRecordType = "*"

WildcardRecordType is a special record type that applies to all record types

Variables

View Source
var EmptyRows = NewRows(emptyRowsIter(0))

EmptyRows is a convenient variable that acts as an empty Rows. Useful for skydb implementators and testing.

View Source
var ErrDatabaseIsReadOnly = errors.New("skydb: database is read only")

ErrDatabaseIsReadOnly is returned by skydb.Database if the requested operation modifies the database and the database is readonly.

View Source
var ErrDatabaseTxDidBegin = errors.New("skydb: a transaction has already begun")
View Source
var ErrDatabaseTxDidNotBegin = errors.New("skydb: a transaction has not begun")
View Source
var ErrDatabaseTxDone = errors.New("skydb: Database's transaction has already committed or rolled back")
View Source
var ErrDeviceNotFound = errors.New("skydb: Specific device not found")

ErrDeviceNotFound is returned by Conn.GetDevice, Conn.DeleteDevice, Conn.DeleteDevicesByToken and Conn.DeleteEmptyDevicesByTime, if the desired Device cannot be found in the current container

View Source
var ErrRecordNotFound = errors.New("skydb: Record not found for the specified key")

ErrRecordNotFound is returned from Get and Delete when Database cannot find the Record by the specified key

View Source
var ErrRoleUpdatesFailed = errors.New("skydb: Update of user roles failed")
View Source
var ErrSubscriptionNotFound = errors.New("skydb: Subscription ID not found")

ErrSubscriptionNotFound is returned from GetSubscription or DeleteSubscription when the specific subscription cannot be found.

View Source
var ErrUserDuplicated = errors.New("skydb: duplicated UserID or Username")

ErrUserDuplicated is returned by Conn.CreateAuth when the AuthInfo to be created has the same ID/username in the current container

View Source
var ErrUserNotFound = errors.New("skydb: AuthInfo ID not found")

ErrUserNotFound is returned by Conn.GetAuth, Conn.UpdateAuth and Conn.DeleteAuth when the AuthInfo's ID is not found in the current container

View Source
var PublicDatabaseIdentifier = "_public"
View Source
var UnionDatabaseIdentifier = "_union"
View Source
var ZeroTime = time.Time{}

ZeroTime represent a zero time.Time. It is used in DeleteDevicesByToken and DeleteEmptyDevicesByTime to signify a Delete without time constraint.

Functions

func MockTimeNowForTestingOnly added in v1.3.2

func MockTimeNowForTestingOnly(f func() time.Time) func()

func Register

func Register(name string, driver Driver)

Register makes an Skygear Server database driver available with the given name.

Register panics if it is called with a nil driver or the same driver name is being registered twice.

func WithTransaction added in v1.1.0

func WithTransaction(tx Transactional, do func() error) (err error)

Types

type APSSetting

type APSSetting struct {
	Alert                      *AppleAlert `json:"alert,omitempty"`
	SoundName                  string      `json:"sound,omitempty"`
	ShouldBadge                bool        `json:"should-badge,omitempty"`
	ShouldSendContentAvailable bool        `json:"should-send-content-available,omitempty"`
}

APSSetting describes how server should send a notification to a targeted device via Apple Push Service.

type AccessControlOptions added in v1.3.0

type AccessControlOptions struct {
	ViewAsUser          *AuthInfo
	BypassAccessControl bool
}

AccessControlOptions provide access control options to query.

The following fields are generated from the server side, rather than supplied from the client side.

type AccessModel

type AccessModel int

AccessModel indicates the type of access control model while db query.

const (
	RoleBasedAccess AccessModel = iota + 1
	RelationBasedAccess
)

RoleBasedAccess is traditional Role based Access Control RelationBasedAccess is Access Control determine by the user-user relation between creator and accessor

func GetAccessModel

func GetAccessModel(accessString string) AccessModel

GetAccessModel convert the string config to internal const

func (AccessModel) String

func (i AccessModel) String() string

type AppleAlert

type AppleAlert struct {
	Body                  string   `json:"body,omitempty"`
	LocalizationKey       string   `json:"loc-key,omitempty"`
	LocalizationArgs      []string `json:"loc-args,omitempty"`
	LaunchImage           string   `json:"launch-image,omitempty"`
	ActionLocalizationKey string   `json:"action-loc-key,omitempty"`
}

AppleAlert describes how a remote notification behaves and shows itself when received.

It is a subset of attributes defined in Apple's "Local and Remote Notification Programming Guide". Please follow the following link for detailed description of the attributes.

https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW20

type Asset

type Asset struct {
	Name        string
	ContentType string
	Size        int64
	Public      bool
	Signer      asset.URLSigner
}

func (*Asset) SignedURL

func (a *Asset) SignedURL() string

SignedURL will try to return a signedURL with the injected Signer.

type AuthData added in v1.1.0

type AuthData struct {
	// contains filtered or unexported fields
}

AuthData contains the unique authentication data of a user e.g.: {"username": "userA", "email": "userA@abc.com"}

func NewAuthData added in v1.1.0

func NewAuthData(data map[string]interface{}, authRecordKeys [][]string) AuthData

func (AuthData) GetData added in v1.1.0

func (a AuthData) GetData() map[string]interface{}

func (AuthData) IsEmpty added in v1.1.0

func (a AuthData) IsEmpty() bool

IsEmpty would return true if

1. no entries or 2. all values are null

func (AuthData) IsValid added in v1.1.0

func (a AuthData) IsValid() bool

func (AuthData) MakeEqualPredicate added in v1.1.0

func (a AuthData) MakeEqualPredicate() Predicate

func (*AuthData) UpdateFromRecordData added in v1.1.0

func (a *AuthData) UpdateFromRecordData(data Data)

type AuthInfo

type AuthInfo struct {
	ID              string       `json:"_id"`
	HashedPassword  []byte       `json:"password,omitempty"`
	Roles           []string     `json:"roles,omitempty"`
	ProviderInfo    ProviderInfo `json:"provider_info,omitempty"` // auth data for alternative methods
	TokenValidSince *time.Time   `json:"token_valid_since,omitempty"`
	LastSeenAt      *time.Time   `json:"last_seen_at,omitempty"`
	IsPasswordSet   bool
	Disabled        bool       `json:"disabled"`
	DisabledMessage string     `json:"disabled_message,omitempty"`
	DisabledExpiry  *time.Time `json:"disabled_expiry,omitempty"`
}

AuthInfo contains a user's information for authentication purpose

func NewAnonymousAuthInfo added in v1.1.0

func NewAnonymousAuthInfo() AuthInfo

NewAnonymousAuthInfo returns an anonymous AuthInfo, which has no Password.

func NewAuthInfo added in v1.1.0

func NewAuthInfo(password string) AuthInfo

NewAuthInfo returns a new AuthInfo with specified password. An UUID4 ID will be generated by the system as unique identifier

func NewProviderInfoAuthInfo added in v1.1.0

func NewProviderInfoAuthInfo(principalID string, authData map[string]interface{}) AuthInfo

NewProviderInfoAuthInfo returns an AuthInfo provided by a AuthProvider, which has no Password.

func (*AuthInfo) GetProviderInfoData added in v1.1.0

func (info *AuthInfo) GetProviderInfoData(principalID string) map[string]interface{}

GetProviderInfoData gets the auth data for the specified principal.

func (*AuthInfo) HasAllRoles added in v1.1.0

func (info *AuthInfo) HasAllRoles(roles []string) bool

HasAllRoles return true if authinfo has all roles supplied

func (*AuthInfo) HasAnyRoles added in v1.1.0

func (info *AuthInfo) HasAnyRoles(roles []string) bool

HasAnyRoles return true if authinfo belongs to one of the supplied roles

func (*AuthInfo) IsDisabled added in v1.4.0

func (info *AuthInfo) IsDisabled() bool

IsDisabled returns true if the user is disabled.

This function checks whether the user is disabled by also considering the expiry of disabling the user account. Use this function instead of using the Disabled field.

func (*AuthInfo) IsPasswordChanged added in v1.3.2

func (info *AuthInfo) IsPasswordChanged() bool

IsPasswordChanged determines password was changed with SetPassword. It is useful for auditing since password history must be saved when password is changed.

func (*AuthInfo) IsPasswordExpired added in v1.3.2

func (info *AuthInfo) IsPasswordExpired(expiryDays int) bool

IsPasswordExpired determines whether the password is expired It returns false if the authinfo is not password-based.

func (AuthInfo) IsSamePassword added in v1.1.0

func (info AuthInfo) IsSamePassword(password string) bool

IsSamePassword determines whether the specified password is the same password as where the HashedPassword is generated from

func (*AuthInfo) RefreshDisabledStatus added in v1.4.0

func (info *AuthInfo) RefreshDisabledStatus()

RefreshDisabledStatus set the auth info as not disabled.

func (*AuthInfo) RemoveProviderInfoData added in v1.1.0

func (info *AuthInfo) RemoveProviderInfoData(principalID string)

RemoveProviderInfoData remove the auth data for the specified principal.

func (*AuthInfo) SetPassword added in v1.1.0

func (info *AuthInfo) SetPassword(password string)

SetPassword sets the HashedPassword with the password specified

func (*AuthInfo) SetProviderInfoData added in v1.1.0

func (info *AuthInfo) SetProviderInfoData(principalID string, authData map[string]interface{})

SetProviderInfoData sets the auth data to the specified principal.

type Conn

type Conn interface {

	// CreateAuth creates a new AuthInfo in the container
	// this Conn associated to.
	CreateAuth(authinfo *AuthInfo) error

	// GetAuth fetches the AuthInfo with supplied ID in the container and
	// fills in the supplied AuthInfo with the result.
	//
	// GetAuth returns ErrUserNotFound if no AuthInfo exists
	// for the supplied ID.
	GetAuth(id string, authinfo *AuthInfo) error

	// GetAuthByPrincipalID fetches the AuthInfo with supplied principal ID in the
	// container and fills in the supplied AuthInfo with the result.
	//
	// Principal ID is an ID of an authenticated principal with such
	// authentication provided by AuthProvider.
	//
	// GetAuthByPrincipalID returns ErrUserNotFound if no AuthInfo exists
	// for the supplied principal ID.
	GetAuthByPrincipalID(principalID string, authinfo *AuthInfo) error

	// UpdateAuth updates an existing AuthInfo matched by the ID field.
	//
	// UpdateAuth returns ErrUserNotFound if such AuthInfo does not
	// exist in the container.
	UpdateAuth(authinfo *AuthInfo) error

	// DeleteAuth removes AuthInfo with the supplied ID in the container.
	//
	// DeleteAuth returns ErrUserNotFound if such AuthInfo does not
	// exist in the container.
	DeleteAuth(id string) error

	// GetPasswordHistory returns a slice of PasswordHistory of the given user
	//
	// If historySize is greater than 0, the returned slice contains history
	// of that size.
	// If historyDays is greater than 0, the returned slice contains history
	// up to now.
	//
	// If both historySize and historyDays are greater than 0, the returned slice
	// is the longer of the result.
	GetPasswordHistory(authID string, historySize, historyDays int) ([]PasswordHistory, error)

	// RemovePasswordHistory removes old password history.
	// It uses GetPasswordHistory to query active history and then purge old history.
	RemovePasswordHistory(authID string, historySize, historyDays int) error

	// GetAdminRoles return the current admine roles
	GetAdminRoles() ([]string, error)

	// SetAdminRoles accepts array of role, the order will be
	SetAdminRoles(roles []string) error

	// GetDefaultRoles return the current default roles
	GetDefaultRoles() ([]string, error)

	// SetDefaultRoles accepts array of roles, the supplied roles will assigned
	// to newly created user CreateAuth
	SetDefaultRoles(roles []string) error

	// AssignRoles accepts array of roles and userID, the supplied roles will
	// be assigned to all passed in users
	AssignRoles(userIDs []string, roles []string) error

	// RevokeRoles accepts array of roles and userID, the supplied roles will
	// be revoked from all passed in users
	RevokeRoles(userIDs []string, roles []string) error

	// GetRoles returns roles of users specified by user IDs
	GetRoles(userIDs []string) (map[string][]string, error)

	// SetRecordAccess sets default record access of a specific type
	SetRecordAccess(recordType string, acl RecordACL) error

	// SetRecordDefaultAccess sets default record access of a specific type
	SetRecordDefaultAccess(recordType string, acl RecordACL) error

	// GetRecordAccess returns the record creation access of a specific type
	GetRecordAccess(recordType string) (RecordACL, error)

	// GetRecordDefaultAccess returns default record access of a specific type
	GetRecordDefaultAccess(recordType string) (RecordACL, error)

	// SetRecordFieldAccess replace field ACL setting
	SetRecordFieldAccess(acl FieldACL) (err error)

	// GetRecordFieldAccess retrieve field ACL setting
	GetRecordFieldAccess() (FieldACL, error)

	// GetAsset retrieves Asset information by its name
	GetAsset(name string, asset *Asset) error

	GetAssets(names []string) ([]Asset, error)

	// SaveAsset saves an Asset information into a container to
	// be referenced by records.
	SaveAsset(asset *Asset) error

	QueryRelation(user string, name string, direction string, config QueryConfig) []AuthInfo
	QueryRelationCount(user string, name string, direction string) (uint64, error)
	AddRelation(user string, name string, targetUser string) error
	RemoveRelation(user string, name string, targetUser string) error

	GetDevice(id string, device *Device) error

	// QueryDevicesByUser queries the Device database which are registered
	// by the specified user.
	QueryDevicesByUser(user string) ([]Device, error)
	QueryDevicesByUserAndTopic(user, topic string) ([]Device, error)
	SaveDevice(device *Device) error
	DeleteDevice(id string) error

	// DeleteDevicesByToken deletes device where its Token == token and
	// LastRegisteredAt < t. If t == ZeroTime, LastRegisteredAt is not considered.
	//
	// If such device does not exist, ErrDeviceNotFound is returned.
	DeleteDevicesByToken(token string, t time.Time) error

	// DeleteEmptyDevicesByTime deletes device where Token is empty and
	// LastRegisteredAt < t. If t == ZeroTime, LastRegisteredAt is not considered.
	//
	// If such device does not exist, ErrDeviceNotFound is returned.
	DeleteEmptyDevicesByTime(t time.Time) error

	PublicDB() Database
	PrivateDB(userKey string) Database
	UnionDB() Database

	// Subscribe registers the specified recordEventChan to receive
	// RecordEvent from the Conn implementation
	Subscribe(recordEventChan chan RecordEvent) error

	// EnsureAuthRecordKeysExist check if authRecordKeys exist in
	// user record schema
	EnsureAuthRecordKeysExist(authRecordKeys [][]string) error

	// EnsureAuthRecordKeysIndexesExist check if indexes of user record schema
	// match with authRecordKeys, so that:
	//
	// 1. indexes of authRecordKeys exist, if not and in dev mode, indexes with
	//    special name would be created
	//
	// 2. indexes of old authRecordKeys with special name does not exist, if
	//    found and in dev mode, they would be removed
	EnsureAuthRecordKeysIndexesMatch(authRecordKeys [][]string) error

	// CreateOAuthInfo creates a new OAuthInfo in the container
	// this Conn associated to.
	CreateOAuthInfo(oauthinfo *OAuthInfo) error

	// GetOAuthInfo fetches the OAuthInfo with supplied provider and principalID
	// in the container and fills in the supplied OAuthInfo with the result.
	//
	// GetOAuthInfo returns ErrUserNotFound if no OAuthInfo exists
	// for the supplied provider and principalID.
	GetOAuthInfo(provider string, principalID string, oauthinfo *OAuthInfo) error

	// GetOAuthInfoByProviderAndUserID fetches the OAuthInfo with supplied provider and userID
	// in the container and fills in the supplied OAuthInfo with the result.
	//
	// GetOAuthInfo returns ErrUserNotFound if no OAuthInfo exists
	// for the supplied provider and userID.
	GetOAuthInfoByProviderAndUserID(provider string, userID string, oauthinfo *OAuthInfo) error

	// UpdateOAuthInfo updates an existing OAuthInfo matched by the
	// provider and principalID.
	//
	// UpdateOAuthInfo returns ErrUserNotFound if such OAuthInfo does not
	// exist in the container.
	UpdateOAuthInfo(oauthinfo *OAuthInfo) error

	// DeleteOAuth removes OAuthInfo with the
	// supplied provider and principalID in the container for unlink provider.
	//
	// DeleteOAuth returns ErrUserNotFound if
	// such OAuthInfo does not exist in the container.
	DeleteOAuth(provider string, principalID string) error

	Close() error

	CustomTokenConn
}

Conn encapsulates the interface of an Skygear Server connection to a container.

func Open

func Open(ctx context.Context, implName string, appName string, accessString string, optionString string, config DBConfig) (Conn, error)

Open returns an implementation of Conn to use w.r.t implName.

optionString is passed to the driver and is implementation specific. For example, in a SQL implementation it will be something like "sql://localhost/db0"

type CountFunc

type CountFunc struct {
	OverallRecords bool
}

CountFunc represents a function that count number of rows matching a query

func (CountFunc) Args

func (f CountFunc) Args() []interface{}

Args implements the Func interface

func (CountFunc) DataType added in v0.23.0

func (f CountFunc) DataType() DataType

type CustomTokenConn added in v1.3.0

type CustomTokenConn interface {
	GetCustomTokenInfo(principalID string, tokenInfo *CustomTokenInfo) error
	CreateCustomTokenInfo(tokenInfo *CustomTokenInfo) error
	DeleteCustomTokenInfo(principalID string) error
}

type CustomTokenInfo added in v1.3.0

type CustomTokenInfo struct {
	UserID      string     `json:"user_id"`
	PrincipalID string     `json:"principal_id"`
	CreatedAt   *time.Time `json:"created_at,omitempty"`
}

type DBConfig added in v1.3.2

type DBConfig struct {
	CanMigrate             bool
	PasswordHistoryEnabled bool
}

DBConfig represents optional configuration. The zero value is sensible defaults.

type DBHookFunc

type DBHookFunc func(Database, *Record, RecordHookEvent)

DBHookFunc specifies the interface of a database hook function

type DBOpener added in v1.3.2

type DBOpener func(context.Context, string, string, string, string, DBConfig) (Conn, error)

DBOpener aliases the function for opening Conn

type Data

type Data map[string]interface{}

A Data represents a key-value object used for storing ODRecord.

func (Data) Copy added in v1.1.0

func (d Data) Copy() Data

Copy makes a shadow copy of itself

type DataType

type DataType uint

DataType defines the type of data that can saved into an skydb database

const (
	TypeString DataType = iota + 1
	TypeNumber
	TypeBoolean
	TypeJSON
	TypeReference
	TypeLocation
	TypeDateTime
	TypeAsset
	TypeACL
	TypeInteger
	TypeSequence
	TypeGeometry
	TypeUnknown
)

List of persistable data types in skydb

func (DataType) IsGeometryCompatibleType added in v0.23.0

func (t DataType) IsGeometryCompatibleType() bool

func (DataType) IsNumberCompatibleType

func (t DataType) IsNumberCompatibleType() bool

IsNumberCompatibleType returns true if the type is a numeric type

func (DataType) String

func (i DataType) String() string

type Database

type Database interface {

	// Conn returns the parent Conn of the Database
	Conn() Conn

	// ID returns the identifier of the Database.
	// We have public and private database. For public DB, the ID is
	// `_public`; for union DB, the ID is `_union`;
	// for private, the ID is the user identifier
	ID() string

	// DatabaseType returns the DatabaseType of the database.
	DatabaseType() DatabaseType

	// UserRecordType returns name of the user record type.
	UserRecordType() string

	// TableName returns the fully qualified name of a table.
	TableName(table string) string

	// IsReadOnly returns true if the database is read only
	IsReadOnly() bool

	// RemoteColumnTypes returns a typemap of a database table.
	RemoteColumnTypes(recordType string) (RecordSchema, error)

	// Get fetches the Record identified by the supplied key and
	// writes it onto the supplied Record.
	//
	// Get returns an ErrRecordNotFound if Record identified by
	// the supplied key does not exist in the Database.
	// It also returns error if the underlying implementation
	// failed to read the Record.
	Get(id RecordID, record *Record) error
	GetByIDs(ids []RecordID, accessControlOptions *AccessControlOptions) (*Rows, error)

	// Save updates the supplied Record in the Database if Record with
	// the same key exists, else such Record is created.
	//
	// Save returns an error if the underlying implementation failed to
	// create / modify the Record.
	Save(record *Record) error

	// Delete removes the Record identified by the key in the Database.
	//
	// Delete returns an ErrRecordNotFound if the Record identified by
	// the supplied key does not exist in the Database.
	// It also returns an error if the underlying implementation
	// failed to remove the Record.
	Delete(id RecordID) error

	// Query executes the supplied query against the Database and returns
	// an Rows to iterate the results.
	Query(query *Query, accessControlOptions *AccessControlOptions) (*Rows, error)

	// QueryCount executes the supplied query against the Database and returns
	// the number of records matching the query's predicate.
	QueryCount(query *Query, accessControlOptions *AccessControlOptions) (uint64, error)

	// Extend extends the Database record schema such that a record
	// arrived subsequently with that schema can be saved
	//
	// Extend returns an bool indicating whether the schema is really extended.
	// Extend also returns an error if the specified schema conflicts with
	// existing schema in the Database
	Extend(recordType string, schema RecordSchema) (extended bool, err error)

	// RenameSchema renames a column of the Database record schema
	RenameSchema(recordType, oldColumnName, newColumnName string) error

	// DeleteSchema removes a column of the Database record schema
	DeleteSchema(recordType, columnName string) error

	// GetSchema returns the record schema of a record type
	GetSchema(recordType string) (RecordSchema, error)

	// FetchRecordTypes returns a list of all existing record type
	GetRecordSchemas() (map[string]RecordSchema, error)

	GetSubscription(key string, deviceID string, subscription *Subscription) error
	SaveSubscription(subscription *Subscription) error
	DeleteSubscription(key string, deviceID string) error
	GetSubscriptionsByDeviceID(deviceID string) []Subscription
	GetMatchingSubscriptions(record *Record) []Subscription

	GetIndexesByRecordType(recordType string) (indexes map[string]Index, err error)
	SaveIndex(recordType, indexName string, index Index) error
	DeleteIndex(recordType string, indexName string) error
}

Database represents a collection of record (either public or private) in a container.

type DatabaseType

type DatabaseType int
const (
	// PublicDatabase is a database containing records shared among all
	// users. ACL settings may apply to restrict access.
	PublicDatabase DatabaseType = 0 + iota

	// PrivateDatabase is a database containing records visible to
	// an individual user. Each individual user has their own private
	// database. ACL settings do not apply.
	PrivateDatabase

	// UnionDatabase is a database containing all records in the PublicDatabase
	// and all PrivateDatabase. This database is only intended for admin
	// user and ACL settings do not apply.
	UnionDatabase
)

type Device

type Device struct {
	ID               string
	Type             string
	Token            string
	AuthInfoID       string
	Topic            string
	LastRegisteredAt time.Time
}

Device represents a device owned by a user and ready to receive notification.

type DistanceFunc

type DistanceFunc struct {
	Field    string
	Location Location
}

DistanceFunc represents a function that calculates distance between a user supplied location and a Record's field

func (DistanceFunc) Args

func (f DistanceFunc) Args() []interface{}

Args implements the Func interface

func (DistanceFunc) DataType added in v0.23.0

func (f DistanceFunc) DataType() DataType

func (DistanceFunc) ReferencedKeyPaths added in v1.1.0

func (f DistanceFunc) ReferencedKeyPaths() []string

ReferencedKeyPaths implements the KeyPathFunc interface.

type Driver

type Driver interface {
	Open(ctx context.Context, appName string, accessModel AccessModel, optionString string, config DBConfig) (Conn, error)
}

Driver opens an connection to the underlying database.

type DriverFunc

type DriverFunc func(ctx context.Context, appName string, accessModel AccessModel, optionString string, config DBConfig) (Conn, error)

The DriverFunc type is an adapter such that an ordinary function can be used as a Driver.

func (DriverFunc) Open

func (f DriverFunc) Open(ctx context.Context, appName string, accessModel AccessModel, name string, config DBConfig) (Conn, error)

Open returns a Conn by calling the DriverFunc itself.

type Expression

type Expression struct {
	Type  ExpressionType
	Value interface{}
}

An Expression represents value to be compared against.

func (Expression) Accept added in v1.1.0

func (expr Expression) Accept(visitor Visitor)

Accept implements the Visitor pattern.

func (Expression) IsEmpty

func (expr Expression) IsEmpty() bool

func (Expression) IsKeyPath

func (expr Expression) IsKeyPath() bool

func (Expression) IsLiteralArray

func (expr Expression) IsLiteralArray() bool

func (Expression) IsLiteralMap

func (expr Expression) IsLiteralMap() bool

func (Expression) IsLiteralNull

func (expr Expression) IsLiteralNull() bool

func (Expression) IsLiteralString

func (expr Expression) IsLiteralString() bool

func (Expression) KeyPathComponents

func (expr Expression) KeyPathComponents() []string

type ExpressionType

type ExpressionType int

ExpressionType is the type of an Expression.

const (
	Literal ExpressionType = iota + 1
	KeyPath
	Function
)

A list of ExpressionTypes.

type ExpressionVisitor added in v1.1.0

type ExpressionVisitor interface {
	VisitExpression(Expression)
	EndVisitExpression(Expression)
}

ExpressionVisitor is an interface that implements the Visitor pattern for the Expression struct.

type FieldACL added in v1.1.0

type FieldACL struct {
	// contains filtered or unexported fields
}

FieldACL contains all field ACL rules for all record types. This struct provides functions for evaluating whether access can be granted for a request.

func NewFieldACL added in v1.1.0

func NewFieldACL(list FieldACLEntryList) FieldACL

NewFieldACL returns a struct of FieldACL with a list of field ACL entries.

func (FieldACL) Accessible added in v1.1.0

func (acl FieldACL) Accessible(
	recordType string,
	field string,
	mode FieldAccessMode,
	authInfo *AuthInfo,
	record *Record,
) bool

Accessible returns true when the access mode is allowed access

The accessibility of a field access request is determined by the first matching rule. If no matching rule is found, the default rule is to grant access.

func (FieldACL) AllEntries added in v1.1.0

func (acl FieldACL) AllEntries() FieldACLEntryList

AllEntries return all ACL entries in FieldACL.

type FieldACLEntry added in v1.1.0

type FieldACLEntry struct {
	RecordType   string        `json:"record_type"`
	RecordField  string        `json:"record_field"`
	UserRole     FieldUserRole `json:"user_role"`
	Writable     bool          `json:"writable"`
	Readable     bool          `json:"readable"`
	Comparable   bool          `json:"comparable"`
	Discoverable bool          `json:"discoverable"`
}

FieldACLEntry contains a single field ACL entry

func (FieldACLEntry) Accessible added in v1.1.0

func (entry FieldACLEntry) Accessible(mode FieldAccessMode) bool

Accessible returns true when the entry grants access for the specified access mode. This function does not consider whether the entry matches the user role or record type.

func (FieldACLEntry) Compare added in v1.1.0

func (entry FieldACLEntry) Compare(other FieldACLEntry) int

Compare the order for evaluation with the other entry.

This function returns negative when the specified entry have a lower priority.

type FieldACLEntryList added in v1.1.0

type FieldACLEntryList []FieldACLEntry

FieldACLEntryList contains a list of field ACL entries

func (FieldACLEntryList) Len added in v1.1.0

func (list FieldACLEntryList) Len() int

func (FieldACLEntryList) Less added in v1.1.0

func (list FieldACLEntryList) Less(i, j int) bool

func (FieldACLEntryList) Swap added in v1.1.0

func (list FieldACLEntryList) Swap(i, j int)

type FieldACLIterator added in v1.1.0

type FieldACLIterator struct {
	// contains filtered or unexported fields
}

FieldACLIterator iterates FieldACL to find a list of rules that apply to the specified record type and record field.

The iterator does not consider the access mode, the AuthInfo and the Record of individual access. So the result is always the same as long as the FieldACL setting is unchanged. The list of rules can then be considered one by one, which is specific to each individual request.

func NewFieldACLIterator added in v1.1.0

func NewFieldACLIterator(acl FieldACL, recordType, recordField string) *FieldACLIterator

NewFieldACLIterator creates a new iterator.

func (*FieldACLIterator) Next added in v1.1.0

func (i *FieldACLIterator) Next() *FieldACLEntry

Next returns the next FieldACLEntry. If there is no more entries to return, this function will return nil.

type FieldAccessMode added in v1.1.0

type FieldAccessMode int

FieldAccessMode is the intended access operation to be granted access

const (
	// ReadFieldAccessMode means the access mode is for reading
	ReadFieldAccessMode FieldAccessMode = iota + 1

	// WriteFieldAccessMode means the access mode is for writing
	WriteFieldAccessMode

	// DiscoverOrCompareFieldAccessMode means the access mode is for discovery
	// or compare
	DiscoverOrCompareFieldAccessMode

	// CompareFieldAccessMode means the access mode is for query
	CompareFieldAccessMode
)

type FieldType

type FieldType struct {
	Type           DataType
	ReferenceType  string     // used only by TypeReference
	Expression     Expression // used by Computed Keys
	UnderlyingType string     // indicates the underlying (pq) type
}

FieldType represents the kind of data living within a field of a RecordSchema.

func DeriveFieldType added in v0.23.0

func DeriveFieldType(value interface{}) (fieldType FieldType, err error)

DeriveFieldType finds the FieldType of the specified value. nolint: gocyclo

func SimpleNameToFieldType

func SimpleNameToFieldType(s string) (result FieldType, err error)

func TraverseColumnTypes added in v1.1.0

func TraverseColumnTypes(db Database, recordType string, keyPath string) ([]FieldType, error)

TraverseColumnTypes traverse the field type of a key path from database table.

func (FieldType) DefinitionCompatibleTo added in v0.23.0

func (f FieldType) DefinitionCompatibleTo(other FieldType) bool

DefinitionCompatibleTo returns if a value of the specified FieldType can be saved to a database column of this FieldType.

When a FieldType is compatible with another FieldType, it also means it is possible to cast value of a type to another type. Whether the cast is successful is subject to the actual value, whether it will lose number precision for example.

This function is not associative. In other words, `a.fn(b) != b.fn(a)`.

func (FieldType) ToSimpleName

func (f FieldType) ToSimpleName() string

type FieldUserRole added in v1.1.0

type FieldUserRole struct {
	// Type contains the type of the user role.
	Type FieldUserRoleType

	// Data is information specific to the type of user role.
	Data string
}

FieldUserRole contains field user role information and checks whether a user matches the user role.

func NewFieldUserRole added in v1.1.0

func NewFieldUserRole(roleString string) FieldUserRole

NewFieldUserRole returns a FieldUserRole struct from the user role specification.

func ParseFieldUserRole added in v1.1.0

func ParseFieldUserRole(roleString string) (FieldUserRole, error)

ParseFieldUserRole parses a user role string to a FieldUserRole.

func (FieldUserRole) Compare added in v1.1.0

func (r FieldUserRole) Compare(other FieldUserRole) int

Compare compares two FieldUserRole according to the order of evaluation.

func (*FieldUserRole) MarshalJSON added in v1.1.0

func (r *FieldUserRole) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler

func (FieldUserRole) Match added in v1.1.0

func (r FieldUserRole) Match(authinfo *AuthInfo, record *Record) bool

Match returns true if the specifid AuthInfo and Record matches the user role.

If the specified user role type is record dependent, this function returns false if Record is nil.

func (FieldUserRole) String added in v1.1.0

func (r FieldUserRole) String() string

String returns the user role specification in string representation.

func (*FieldUserRole) UnmarshalJSON added in v1.1.0

func (r *FieldUserRole) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements json.Unmarshaler

type FieldUserRoleType added in v1.1.0

type FieldUserRoleType string

FieldUserRoleType denotes the type of field user role, which specify who can access certain fields.

const (
	// OwnerFieldUserRoleType means field is accessible by the record owner.
	OwnerFieldUserRoleType FieldUserRoleType = "_owner"

	// SpecificUserFieldUserRoleType means field is accessible by a specific user.
	SpecificUserFieldUserRoleType FieldUserRoleType = "_user_id"

	// DynamicUserFieldUserRoleType means field is accessible by user contained in another field.
	DynamicUserFieldUserRoleType FieldUserRoleType = "_field"

	// DefinedRoleFieldUserRoleType means field is accessible by a users of specific role.
	DefinedRoleFieldUserRoleType FieldUserRoleType = "_role"

	// AnyUserFieldUserRoleType means field is accessible by any authenticated user.
	AnyUserFieldUserRoleType FieldUserRoleType = "_any_user"

	// PublicFieldUserRoleType means field is accessible by public.
	PublicFieldUserRoleType FieldUserRoleType = "_public"
)

func (FieldUserRoleType) Compare added in v1.1.0

func (userRoleType FieldUserRoleType) Compare(other FieldUserRoleType) int

Compare compares two user role type in the order of evaluation.

func (FieldUserRoleType) RecordDependent added in v1.1.0

func (userRoleType FieldUserRoleType) RecordDependent() bool

RecordDependent returns true if this user role type requires record data when evaluating accessibility.

type FullQueryVisitor added in v1.1.0

type FullQueryVisitor interface {
	QueryVisitor
	PredicateVisitor
	SortVisitor
	ExpressionVisitor
}

FullQueryVisitor is a marker interface for all query-related visitors

type Func

type Func interface {
	Args() []interface{}
	DataType() DataType
}

Func is a marker interface to denote a type being a function in skydb.

skydb's function receives zero or more arguments and returns a DataType as a result. Result data type is currently omitted in this interface since skygear doesn't use it internally yet. In the future it can be utilized to provide more extensive type checking at handler level.

type Geometry added in v0.23.0

type Geometry map[string]interface{}

Geometry represent a geometry in GeoJSON.

type Index added in v1.1.0

type Index struct {
	Fields []string
}

Index indicates the value of fields within a record type cannot be duplicated

type KeyPathFunc added in v1.1.0

type KeyPathFunc interface {
	// Returns a list of key paths that is referenced by this function.
	ReferencedKeyPaths() []string
}

KeyPathFunc is a marker interface to denote a func that references certain key paths.

type Location

type Location [2]float64

Location represent a point of geometry.

It being an array of two floats is intended to provide no-copy conversion between paulmach/orb.

func NewLocation

func NewLocation(lng, lat float64) Location

NewLocation returns a new Location

func (Location) Lat

func (loc Location) Lat() float64

Lat returns the Latitude

func (Location) Lng

func (loc Location) Lng() float64

Lng returns the longitude

func (Location) String

func (loc Location) String() string

String returns a human-readable representation of this Location. Coincidentally it is in WKT.

type MemoryRows

type MemoryRows struct {
	CurrentRowIndex int
	Records         []Record
}

MemoryRows is a native implementation of RowIter. Can be used in test not support cursor.

func NewMemoryRows

func NewMemoryRows(records []Record) *MemoryRows

func (*MemoryRows) Close

func (rs *MemoryRows) Close() error

func (*MemoryRows) Next

func (rs *MemoryRows) Next(record *Record) error

func (*MemoryRows) OverallRecordCount

func (rs *MemoryRows) OverallRecordCount() *uint64

type NotificationInfo

type NotificationInfo struct {
	APS APSSetting `json:"aps,omitempty"`
}

NotificationInfo describes how server should send a notification to a target devices via a push service. Currently only APS is supported.

type OAuthInfo added in v1.2.0

type OAuthInfo struct {
	UserID          string          `json:"user_id"`
	Provider        string          `json:"provider"`
	PrincipalID     string          `json:"principal_id"`
	TokenResponse   TokenResponse   `json:"token_response,omitempty"`
	ProviderProfile ProviderProfile `json:"profile,omitempty"`
	CreatedAt       *time.Time      `json:"created_at,omitempty"`
	UpdatedAt       *time.Time      `json:"updated_at,omitempty"`
}

OAuthInfo contains 3rd provider information for authentication

UserID is AuthInfo ID which incidcate user who link with the given oauth data

type Operator

type Operator int

Operator denotes how the result of a predicate is determined from its subpredicates or subexpressions.

const (
	And Operator = iota + 1
	Or
	Not
	Equal
	GreaterThan
	LessThan
	GreaterThanOrEqual
	LessThanOrEqual
	NotEqual
	Like
	ILike
	In
	Functional
)

A list of Operator.

func (Operator) IsBinary

func (op Operator) IsBinary() bool

IsBinary checks whether the Operator determines the result of a predicate by comparing two subexpressions.

func (Operator) IsCommutative

func (op Operator) IsCommutative() bool

IsCommutative checks whether expressions on both side of the Operator can be swapped.

func (Operator) IsCompound

func (op Operator) IsCompound() bool

IsCompound checks whether the Operator is a compound operator, meaning the operator combine the results of other subpredicates.

func (Operator) String

func (i Operator) String() string

type PasswordHistory added in v1.3.2

type PasswordHistory struct {
	ID             string
	AuthID         string
	HashedPassword []byte
	LoggedAt       time.Time
}

PasswordHistory contains a password history of a user

type Predicate

type Predicate struct {
	Operator Operator
	Children []interface{}
}

Predicate is a representation of used in query for filtering records.

func (Predicate) Accept added in v1.1.0

func (p Predicate) Accept(visitor Visitor)

Accept implements the Visitor pattern.

func (Predicate) GetExpressions

func (p Predicate) GetExpressions() (ps []Expression)

GetExpressions returns Predicate.Children as []Expression.

This method is only valid when Operator is binary operator. Caller is responsible to check for this preconditions. Otherwise the method will panic.

func (Predicate) GetSubPredicates

func (p Predicate) GetSubPredicates() (ps []Predicate)

GetSubPredicates returns Predicate.Children as []Predicate.

This method is only valid when Operator is either And, Or and Not. Caller is responsible to check for this preconditions. Otherwise the method will panic.

func (Predicate) IsEmpty

func (p Predicate) IsEmpty() bool

func (Predicate) Validate

func (p Predicate) Validate() skyerr.Error

Validate returns an Error if a Predicate is invalid.

If a Predicate is validated without error, nil is returned.

type PredicateVisitor added in v1.1.0

type PredicateVisitor interface {
	VisitPredicate(Predicate)
	EndVisitPredicate(Predicate)
}

PredicateVisitor is an interface that implements the Visitor pattern for the Predicate struct.

type ProviderInfo added in v1.1.0

type ProviderInfo map[string]map[string]interface{}

ProviderInfo represents the dictionary of authenticated principal ID => authData.

For example, a AuthInfo connected with a Facebook account might look like this:

{
  "com.facebook:46709394": {
    "accessToken": "someAccessToken",
    "expiredAt": "2015-02-26T20:05:48",
    "facebookID": "46709394"
  }
}

It is assumed that the Facebook AuthProvider has "com.facebook" as provider name and "46709394" as the authenticated Facebook account ID.

type ProviderProfile added in v1.2.0

type ProviderProfile map[string]interface{}

type Query

type Query struct {
	Type         string
	Predicate    Predicate
	Sorts        []Sort
	ComputedKeys map[string]Expression
	DesiredKeys  []string
	GetCount     bool
	Limit        *uint64
	Offset       uint64
}

Query specifies the type, predicate and sorting order of Database query.

func (Query) Accept added in v1.1.0

func (q Query) Accept(visitor Visitor)

Accept implements the Visitor pattern.

type QueryConfig

type QueryConfig struct {
	Limit  uint64
	Offset uint64
}

QueryConfig provides optional parameters for queries. result is unlimited if Limit=0

type QueryVisitor added in v1.1.0

type QueryVisitor interface {
	VisitQuery(Query)
	EndVisitQuery(Query)
}

QueryVisitor is an interface that implements the Visitor pattern for the Query struct.

type Record

type Record struct {
	ID         RecordID
	DatabaseID string `json:"-"`
	OwnerID    string
	CreatedAt  time.Time
	CreatorID  string
	UpdatedAt  time.Time
	UpdaterID  string
	ACL        RecordACL
	Data       Data
	Transient  Data `json:"-"`
}

Record is the primary entity of storage in Skygear.

func (*Record) Accessible

func (r *Record) Accessible(authinfo *AuthInfo, level RecordACLLevel) bool

func (*Record) Apply added in v1.1.0

func (r *Record) Apply(src *Record)

Apply modifies the content of the record with the specified record.

func (*Record) Copy added in v1.1.0

func (r *Record) Copy() Record

Copy copies the content of the record.

func (*Record) Get

func (r *Record) Get(key string) interface{}

Get returns the value specified by key. If no value is associated with the specified key, it returns nil.

Get also supports getting reserved fields starting with "_". If such reserved field does not exists, it returns nil.

func (*Record) MergedCopy added in v1.1.0

func (r *Record) MergedCopy(merge *Record) Record

MergedCopy is similar to copy but the copy contains data dictionary which is creating by copying the original and apply the specified dictionary.

func (*Record) Remove added in v1.1.0

func (r *Record) Remove(key string)

func (*Record) Set

func (r *Record) Set(key string, i interface{})

Set associates key with the value i in this record.

Set is able to associate reserved key name starting with "_" as well. If there is no such key, it panics.

func (*Record) UserKeys added in v1.1.0

func (r *Record) UserKeys() []string

type RecordACL

type RecordACL []RecordACLEntry

RecordACL is a list of ACL entries defining access control for a record

func NewRecordACL

func NewRecordACL(entries []RecordACLEntry) RecordACL

NewRecordACL returns a new RecordACL

func (RecordACL) Accessible

func (acl RecordACL) Accessible(authinfo *AuthInfo, level RecordACLLevel) bool

Accessible checks whether provided user info has certain access level

type RecordACLEntry

type RecordACLEntry struct {
	Relation string         `json:"relation,omitempty"`
	Role     string         `json:"role,omitempty"`
	Level    RecordACLLevel `json:"level"`
	UserID   string         `json:"user_id,omitempty"`
	Public   bool           `json:"public,omitempty"`
}

RecordACLEntry grants access to a record by relation or by user_id

func NewRecordACLEntryDirect

func NewRecordACLEntryDirect(userID string, level RecordACLLevel) RecordACLEntry

NewRecordACLEntryDirect returns an ACE for a specific user

func NewRecordACLEntryPublic

func NewRecordACLEntryPublic(level RecordACLLevel) RecordACLEntry

NewRecordACLEntryPublic return an ACE on public access

func NewRecordACLEntryRelation

func NewRecordACLEntryRelation(relation string, level RecordACLLevel) RecordACLEntry

NewRecordACLEntryRelation returns an ACE on relation

func NewRecordACLEntryRole

func NewRecordACLEntryRole(role string, level RecordACLLevel) RecordACLEntry

NewRecordACLEntryRole return an ACE on role

func (*RecordACLEntry) Accessible

func (ace *RecordACLEntry) Accessible(authinfo *AuthInfo, level RecordACLLevel) bool

func (*RecordACLEntry) AccessibleLevel

func (ace *RecordACLEntry) AccessibleLevel(level RecordACLLevel) bool

type RecordACLLevel added in v1.1.0

type RecordACLLevel string

RecordACLLevel represent the operation a user granted on a resource

const (
	ReadLevel   RecordACLLevel = "read"
	WriteLevel  RecordACLLevel = "write"
	CreateLevel RecordACLLevel = "create"
)

ReadLevel and WriteLevel is self-explanatory

type RecordEvent

type RecordEvent struct {
	Record *Record
	Event  RecordHookEvent
}

RecordEvent describes a change event on Record which is either Created, Updated or Deleted.

For RecordCreated or RecordUpdated event, Record is the newly created / updated Record. For RecordDeleted, Record is the Record being deleted.

type RecordHookEvent

type RecordHookEvent int

RecordHookEvent indicates the type of record event that triggered the hook

const (
	RecordCreated RecordHookEvent = iota + 1
	RecordUpdated
	RecordDeleted
)

See the definition of RecordHookEvent

type RecordID

type RecordID struct {
	Type string
	Key  string
}

RecordID identifies an unique record in a Database

func NewEmptyRecordID

func NewEmptyRecordID() RecordID

func NewRecordID

func NewRecordID(recordType string, id string) RecordID

NewRecordID returns a new RecordID

func (*RecordID) IsEmpty

func (id *RecordID) IsEmpty() bool

IsEmpty returns whether the RecordID is empty.

func (RecordID) MarshalText

func (id RecordID) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextUnmarshaler interface.

func (RecordID) String

func (id RecordID) String() string

String implements the fmt.Stringer interface.

func (*RecordID) UnmarshalText

func (id *RecordID) UnmarshalText(data []byte) error

UnmarshalText implements the encoding.TextMarshaler interface.

type RecordSchema

type RecordSchema map[string]FieldType

RecordSchema is a mapping of record key to its value's data type or reference

func (RecordSchema) DefinitionCompatibleTo added in v0.23.0

func (schema RecordSchema) DefinitionCompatibleTo(other RecordSchema) bool

DefinitionCompatibleTo returns if a record having the specified RecordSchema

can be saved to a database table of this RecordSchema.

This function is not associative. In other words, `a.fn(b) != b.fn(a)`.

func (RecordSchema) HasField added in v1.1.0

func (schema RecordSchema) HasField(field string) bool

func (RecordSchema) HasFields added in v1.1.0

func (schema RecordSchema) HasFields(fields []string) bool

type Reference

type Reference struct {
	ID RecordID
}

func NewEmptyReference

func NewEmptyReference() Reference

NewEmptyReference returns a reference that is empty

func NewReference

func NewReference(recordType string, id string) Reference

func (*Reference) IsEmpty

func (reference *Reference) IsEmpty() bool

IsEmpty returns whether the reference is empty.

func (*Reference) Type

func (reference *Reference) Type() string

type Rows

type Rows struct {
	// contains filtered or unexported fields
}

Rows implements a scanner-like interface for easy iteration on a result set returned from a query

func NewRows

func NewRows(iter RowsIter) *Rows

NewRows creates a new Rows.

Driver implementators are expected to call this method with their implementation of RowsIter to return a Rows from Database.Query.

func (*Rows) Close

func (r *Rows) Close() error

Close closes the Rows and prevents further enumerations on the instance.

func (*Rows) Err

func (r *Rows) Err() error

Err returns the last error encountered during Scan.

NOTE: It is not an error if the underlying result set is exhausted.

func (*Rows) OverallRecordCount

func (r *Rows) OverallRecordCount() *uint64

OverallRecordCount returns the number of matching records in the database if this resultset contains any rows.

func (*Rows) Record

func (r *Rows) Record() Record

Record returns the current record in Rows.

It must be called after calling Scan and Scan returned true. If Scan is not called or previous Scan return false, the behaviour of Record is unspecified.

func (*Rows) Scan

func (r *Rows) Scan() bool

Scan tries to prepare the next record and returns whether such record is ready to be read.

type RowsIter

type RowsIter interface {
	// Close closes the rows iterator
	Close() error

	// Next populates the next Record in the current rows iterator into
	// the provided record.
	//
	// Next should return io.EOF when there are no more rows
	Next(record *Record) error

	OverallRecordCount() *uint64
}

RowsIter is an iterator on results returned by execution of a query.

type Sequence

type Sequence struct{}

Sequence is a bogus data type for creating a sequence field via JIT schema migration

type Sort

type Sort struct {
	Expression Expression
	Order      SortOrder
}

Sort specifies the order of a collection of Records returned from a Query.

Record order can be sorted w.r.t. a record field or a value returned from a predefined function.

func (Sort) Accept added in v1.1.0

func (sort Sort) Accept(visitor Visitor)

Accept implements the Visitor pattern.

type SortOrder

type SortOrder int

SortOrder denotes an the order of Records returned from a Query.

type SortVisitor added in v1.1.0

type SortVisitor interface {
	VisitSort(Sort)
	EndVisitSort(Sort)
}

SortVisitor is an interface that implements the Visitor pattern for the Sort struct.

type Subscription

type Subscription struct {
	ID               string            `json:"id"`
	Type             string            `json:"type"`
	DeviceID         string            `json:"device_id"`
	NotificationInfo *NotificationInfo `json:"notification_info,omitempty"`
	Query            Query             `json:"query"`
}

Subscription represents a device's subscription of notification triggered by changes of results from a query.

type TokenResponse added in v1.2.0

type TokenResponse map[string]interface{}

type Transactional added in v1.1.0

type Transactional interface {
	// Begin opens a transaction for the current storage.
	//
	// Calling Begin on an already Begin'ed storage returns ErrDatabaseTxDidBegin.
	Begin() error

	// Commit saves all the changes made to storage after Begin atomically.
	Commit() error

	// Rollbacks discards all the changes made to storage after Begin.
	Rollback() error
}

Transactional defines the methods for a persistence storage that supports transaction.

A Begin'ed transaction must end with a call to Commit or Rollback. After that, all opertions on the storage will return ErrDatabaseTxDone.

type TxDatabase

type TxDatabase interface {
	Transactional
	Database
}

TxDatabase defines a Transactional Database

type Unknown added in v0.20.0

type Unknown struct {
	UnderlyingType string
}

Unknown is a bogus data type denoting the type of a field is unknown.

type UserRelationFunc

type UserRelationFunc struct {
	KeyPath           string
	RelationName      string
	RelationDirection string
	User              string
}

UserRelationFunc represents a function that is used to evaulate whether a record satisfy certain user-based relation

func (UserRelationFunc) Args

func (f UserRelationFunc) Args() []interface{}

Args implements the Func interface

func (UserRelationFunc) DataType added in v0.23.0

func (f UserRelationFunc) DataType() DataType

func (UserRelationFunc) ReferencedKeyPaths added in v1.1.0

func (f UserRelationFunc) ReferencedKeyPaths() []string

ReferencedKeyPaths implements the KeyPathFunc interface.

type Visitor added in v1.1.0

type Visitor interface{}

Visitor is a marker interface

Directories

Path Synopsis
pq

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL