Documentation
¶
Index ¶
- Constants
- Variables
- func PathLoadStrategyEdgeConstraint(startVariable, startLabel, endLabel, endTargetField string, ...) (dsl.Cypher, error)
- func PathLoadStrategyMany(variable, label string, depth int, additionalConstraints dsl.ConditionOperator) (dsl.Cypher, error)
- func PathLoadStrategyOne(variable, label, fieldOn, paramName string, isGraphId bool, depth int, ...) (dsl.Cypher, error)
- func SetGlobalGogm(gogm *Gogm)
- type BaseNode
- type BaseUUIDNode
- type Config
- type Edge
- type GenerateNewIDFunc
- type Gogm
- type ISession
- type ITransaction
- type IndexStrategy
- type InvalidDecoratorConfigError
- type InvalidStructConfigError
- type LoadStrategy
- type Logger
- type Pagination
- type PrimaryKeyStrategy
- type RelationConfig
- type RelationType
- type Sessiondeprecated
- func (s *Session) Begin() error
- func (s *Session) Close() error
- func (s *Session) Commit() error
- func (s *Session) Delete(deleteObj interface{}) error
- func (s *Session) DeleteUUID(uuid string) error
- func (s *Session) Load(respObj interface{}, id string) error
- func (s *Session) LoadAll(respObj interface{}) error
- func (s *Session) LoadAllDepth(respObj interface{}, depth int) error
- func (s *Session) LoadAllDepthFilter(respObj interface{}, depth int, filter dsl.ConditionOperator, ...) error
- func (s *Session) LoadAllDepthFilterPagination(respObj interface{}, depth int, filter dsl.ConditionOperator, ...) error
- func (s *Session) LoadAllEdgeConstraint(respObj interface{}, endNodeType, endNodeField string, ...) error
- func (s *Session) LoadDepth(respObj interface{}, id string, depth int) error
- func (s *Session) LoadDepthFilter(respObj interface{}, id string, depth int, filter *dsl.ConditionBuilder, ...) error
- func (s *Session) LoadDepthFilterPagination(respObj interface{}, id string, depth int, filter dsl.ConditionOperator, ...) error
- func (s *Session) PurgeDatabase() error
- func (s *Session) Query(query string, properties map[string]interface{}, respObj interface{}) error
- func (s *Session) QueryRaw(query string, properties map[string]interface{}) ([][]interface{}, error)
- func (s *Session) Rollback() error
- func (s *Session) RollbackWithError(originalError error) error
- func (s *Session) Save(saveObj interface{}) error
- func (s *Session) SaveDepth(saveObj interface{}, depth int) error
- type SessionConfig
- type SessionV2
- type SessionV2Impl
- func (s *SessionV2Impl) Begin(ctx context.Context) error
- func (s *SessionV2Impl) Close() error
- func (s *SessionV2Impl) Commit(ctx context.Context) error
- func (s *SessionV2Impl) Delete(ctx context.Context, deleteObj interface{}) error
- func (s *SessionV2Impl) DeleteUUID(ctx context.Context, uuid string) error
- func (s *SessionV2Impl) Load(ctx context.Context, respObj, id interface{}) error
- func (s *SessionV2Impl) LoadAll(ctx context.Context, respObj interface{}) error
- func (s *SessionV2Impl) LoadAllDepth(ctx context.Context, respObj interface{}, depth int) error
- func (s *SessionV2Impl) LoadAllDepthFilter(ctx context.Context, respObj interface{}, depth int, ...) error
- func (s *SessionV2Impl) LoadAllDepthFilterPagination(ctx context.Context, respObj interface{}, depth int, ...) error
- func (s *SessionV2Impl) LoadDepth(ctx context.Context, respObj, id interface{}, depth int) error
- func (s *SessionV2Impl) LoadDepthFilter(ctx context.Context, respObj, id interface{}, depth int, ...) error
- func (s *SessionV2Impl) LoadDepthFilterPagination(ctx context.Context, respObj, id interface{}, depth int, ...) error
- func (s *SessionV2Impl) ManagedTransaction(ctx context.Context, work TransactionWork) error
- func (s *SessionV2Impl) Query(ctx context.Context, query string, properties map[string]interface{}, ...) error
- func (s *SessionV2Impl) QueryRaw(ctx context.Context, query string, properties map[string]interface{}) ([][]interface{}, neo4j.ResultSummary, error)
- func (s *SessionV2Impl) Rollback(ctx context.Context) error
- func (s *SessionV2Impl) RollbackWithError(ctx context.Context, originalError error) error
- func (s *SessionV2Impl) Save(ctx context.Context, saveObj interface{}) error
- func (s *SessionV2Impl) SaveDepth(ctx context.Context, saveObj interface{}, depth int) error
- type TransactionV2
- type TransactionWork
Constants ¶
const AccessModeRead = neo4j.AccessModeRead
const AccessModeWrite = neo4j.AccessModeWrite
Variables ¶
var ( UUIDPrimaryKeyStrategy = &PrimaryKeyStrategy{ StrategyName: "UUID", DBName: "uuid", FieldName: "UUID", Type: reflect.TypeOf(""), GenIDFunc: func() (id interface{}) { return uuid.New().String() }, noop: false, } DefaultPrimaryKeyStrategy = &PrimaryKeyStrategy{ StrategyName: "default", DBName: "id", FieldName: "Id", Type: reflect.TypeOf(int64(1)), GenIDFunc: func() (id interface{}) { return "" }, noop: true, } )
var ErrConfiguration = errors.New("gogm: configuration was malformed")
var ErrConnection = errors.New("gogm: connection error")
var ErrInternal = errors.New("gogm: internal error")
var ErrInvalidParams = errors.New("gogm: invalid params")
var ErrNotFound = errors.New("gogm: data not found")
base errors for gogm 1.13 errors, these are pretty self explanatory
var ErrTransaction = errors.New("gogm: transaction error")
var ErrValidation = errors.New("gogm: struct validation error")
Functions ¶
func PathLoadStrategyEdgeConstraint ¶
func PathLoadStrategyEdgeConstraint(startVariable, startLabel, endLabel, endTargetField string, minJumps, maxJumps, depth int, additionalConstraints dsl.ConditionOperator) (dsl.Cypher, error)
PathLoadStrategyEdgeConstraint is similar to load many, but requires that it is related to another node via some edge
func PathLoadStrategyMany ¶
func PathLoadStrategyMany(variable, label string, depth int, additionalConstraints dsl.ConditionOperator) (dsl.Cypher, error)
PathLoadStrategyMany loads many using path strategy
func PathLoadStrategyOne ¶
func PathLoadStrategyOne(variable, label, fieldOn, paramName string, isGraphId bool, depth int, additionalConstraints dsl.ConditionOperator) (dsl.Cypher, error)
PathLoadStrategyOne loads one object using path strategy
Types ¶
type BaseNode ¶
type BaseNode struct { // Id is the GraphId that neo4j uses internally Id int64 `json:"-" gogm:"pk=default"` // LoadMap represents the state of how a node was loaded for neo4j. // This is used to determine if relationships are removed on save // field -- relations LoadMap map[string]*RelationConfig `json:"-" gogm:"-"` }
BaseNode contains fields that ALL GoGM nodes are required to have
type BaseUUIDNode ¶
type Config ¶
type Config struct { // Host is the neo4j host Host string `yaml:"host" json:"host" mapstructure:"host"` // Port is the neo4j port Port int `yaml:"port" json:"port" mapstructure:"port"` // IsCluster specifies whether GoGM is connecting to a casual cluster or not IsCluster bool `yaml:"is_cluster" json:"is_cluster" mapstructure:"is_cluster"` // Username is the GoGM username Username string `yaml:"username" json:"username" mapstructure:"username"` // Password is the GoGM password Password string `yaml:"password" json:"password" mapstructure:"password"` // PoolSize is the size of the connection pool for GoGM PoolSize int `yaml:"pool_size" json:"pool_size" mapstructure:"pool_size"` DefaultTransactionTimeout time.Duration `json:"default_transaction_timeout" yaml:"default_transaction_timeout" mapstructure:"default_transaction_timeout"` Realm string `yaml:"realm" json:"realm" mapstructure:"realm"` Encrypted bool `yaml:"encrypted" json:"encrypted" mapstructure:"encrypted"` // Index Strategy defines the index strategy for GoGM IndexStrategy IndexStrategy `yaml:"index_strategy" json:"index_strategy" mapstructure:"index_strategy"` TargetDbs []string `yaml:"target_dbs" json:"target_dbs" mapstructure:"target_dbs"` Logger Logger `yaml:"-" json:"-" mapstructure:"-"` // if logger is not nil log level will be ignored LogLevel string `json:"log_level" yaml:"log_level" mapstructure:"log_level"` EnableDriverLogs bool `json:"enable_driver_logs" yaml:"enable_driver_logs" mapstructure:"enable_driver_logs"` // WARNING THIS IS A SECURITY RISK -- ONLY ENABLE THIS FOR DEBUG EnableLogParams bool `json:"enable_log_properties" yaml:"enable_log_properties" mapstructure:"enable_log_properties"` OpentracingEnabled bool `json:"opentracing_enabled" yaml:"opentracing_enabled" mapstructure:"opentracing_enabled"` }
Config Defined GoGM config
func (*Config) ConnectionString ¶
ConnectionString builds the neo4j bolt/bolt+routing connection string
type Edge ¶
type Edge interface { // GetStartNode gets start node of edge GetStartNode() interface{} // GetStartNodeType gets reflect type of start node GetStartNodeType() reflect.Type // SetStartNode sets start node of edge SetStartNode(v interface{}) error // GetEndNode gets end node of edge GetEndNode() interface{} // GetEndNodeType gets reflect type of end node GetEndNodeType() reflect.Type // SetEndNode sets end node of edge SetEndNode(v interface{}) error }
Edge specifies required functions for special edge nodes
type GenerateNewIDFunc ¶
type GenerateNewIDFunc func() interface{}
type Gogm ¶
type Gogm struct {
// contains filtered or unexported fields
}
func New ¶
func New(config *Config, pkStrategy *PrimaryKeyStrategy, mapTypes ...interface{}) (*Gogm, error)
func (*Gogm) NewSession ¶
func (g *Gogm) NewSession(conf SessionConfig) (ISession, error)
func (*Gogm) NewSessionV2 ¶
func (g *Gogm) NewSessionV2(conf SessionConfig) (SessionV2, error)
type ISession ¶
type ISession interface { //transaction functions ITransaction //load single object Load(respObj interface{}, id string) error //load object with depth LoadDepth(respObj interface{}, id string, depth int) error //load with depth and filter LoadDepthFilter(respObj interface{}, id string, depth int, filter *dsl.ConditionBuilder, params map[string]interface{}) error //load with depth, filter and pagination LoadDepthFilterPagination(respObj interface{}, id string, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error //load slice of something LoadAll(respObj interface{}) error //load all of depth LoadAllDepth(respObj interface{}, depth int) error //load all of type with depth and filter LoadAllDepthFilter(respObj interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}) error //load all with depth, filter and pagination LoadAllDepthFilterPagination(respObj interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error //load all edge query LoadAllEdgeConstraint(respObj interface{}, endNodeType, endNodeField string, edgeConstraint interface{}, minJumps, maxJumps, depth int, filter dsl.ConditionOperator) error //save object Save(saveObj interface{}) error //save object with depth SaveDepth(saveObj interface{}, depth int) error //delete Delete(deleteObj interface{}) error //delete uuid DeleteUUID(uuid string) error //specific query, responds to slice and single objects Query(query string, properties map[string]interface{}, respObj interface{}) error //similar to query, but returns raw rows/cols QueryRaw(query string, properties map[string]interface{}) ([][]interface{}, error) //delete everything, this will literally delete everything PurgeDatabase() error // closes session Close() error }
deprecated session object for ogm interactions
type ITransaction ¶
type ITransaction interface { // Begin begins transaction Begin() error // Rollback rolls back transaction Rollback() error // RollbackWithError wraps original error into rollback error if there is one RollbackWithError(err error) error // Commit commits transaction Commit() error }
ITransaction specifies functions for Neo4j ACID transactions
type IndexStrategy ¶
type IndexStrategy int
Index Strategy typedefs int to define different index approaches
const ( // ASSERT_INDEX ensures that all indices are set and sets them if they are not there ASSERT_INDEX IndexStrategy = 0 // VALIDATE_INDEX ensures that all indices are set VALIDATE_INDEX IndexStrategy = 1 // IGNORE_INDEX skips the index step of setup IGNORE_INDEX IndexStrategy = 2 )
type InvalidDecoratorConfigError ¶
func NewInvalidDecoratorConfigError ¶
func NewInvalidDecoratorConfigError(issue, field string) *InvalidDecoratorConfigError
func (*InvalidDecoratorConfigError) Error ¶
func (i *InvalidDecoratorConfigError) Error() string
type InvalidStructConfigError ¶
type InvalidStructConfigError struct {
// contains filtered or unexported fields
}
func NewInvalidStructConfigError ¶
func NewInvalidStructConfigError(issue string) *InvalidStructConfigError
func (*InvalidStructConfigError) Error ¶
func (i *InvalidStructConfigError) Error() string
type LoadStrategy ¶
type LoadStrategy int
Specifies query based load strategy
const ( // PathLoadStrategy uses cypher path PATH_LOAD_STRATEGY LoadStrategy = iota // SchemaLoadStrategy generates queries specifically from generated schema SCHEMA_LOAD_STRATEGY )
type Logger ¶
type Logger interface { Debug(s string) Debugf(s string, vals ...interface{}) Info(s string) Infof(s string, vals ...interface{}) Warn(s string) Warnf(s string, vals ...interface{}) Error(s string) Errorf(s string, vals ...interface{}) Fatal(s string) Fatalf(s string, vals ...interface{}) }
func GetDefaultLogger ¶
func GetDefaultLogger() Logger
type Pagination ¶
type Pagination struct { // specifies which page number to load PageNumber int // limits how many records per page LimitPerPage int // specifies variable to order by OrderByVarName string // specifies field to order by on OrderByField string // specifies whether orderby is desc or asc OrderByDesc bool }
pagination configuration
func (*Pagination) Validate ¶
func (p *Pagination) Validate() error
type PrimaryKeyStrategy ¶
type PrimaryKeyStrategy struct { // StrategyName is the name of strategy to map field StrategyName string // DBName for field in the database DBName string FieldName string // Type of uuid Type reflect.Type // GenIDFunc function to generate new id GenIDFunc GenerateNewIDFunc // contains filtered or unexported fields }
type RelationConfig ¶
type RelationConfig struct { // stores graph ids Ids []int64 `json:"-" gomg:"-"` // specifies relationship type RelationType RelationType `json:"-" gomg:"-"` }
RelationConfig specifies how relationships are loaded
type RelationType ¶
type RelationType int
Specifies Type of testRelationship
const ( // Side of relationship can only point to 0 or 1 other nodes Single RelationType = 0 // Side of relationship can point to 0+ other nodes Multi RelationType = 1 )
type Session
deprecated
type Session struct { DefaultDepth int LoadStrategy LoadStrategy // contains filtered or unexported fields }
Deprecated: Session will be removed in a later release in favor of SessionV2
func NewSession ¶
uses global gogm Deprecated: Gogm.NewSession instead
func NewSessionWithConfig
deprecated
func NewSessionWithConfig(conf SessionConfig) (*Session, error)
Deprecated: Gogm.NewSessionWithConfig instead
func (*Session) DeleteUUID ¶
func (*Session) LoadAllDepth ¶
func (*Session) LoadAllDepthFilter ¶
func (*Session) LoadAllDepthFilterPagination ¶
func (s *Session) LoadAllDepthFilterPagination(respObj interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error
func (*Session) LoadAllEdgeConstraint ¶
func (*Session) LoadDepthFilter ¶
func (*Session) LoadDepthFilterPagination ¶
func (s *Session) LoadDepthFilterPagination(respObj interface{}, id string, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error
func (*Session) PurgeDatabase ¶
func (*Session) RollbackWithError ¶
type SessionConfig ¶
type SessionConfig neo4j.SessionConfig
type SessionV2 ¶
type SessionV2 interface { //transaction functions TransactionV2 // Begin begins transaction Begin(ctx context.Context) error // ManagedTransaction runs tx work managed for retry ManagedTransaction(ctx context.Context, work TransactionWork) error // closes session Close() error }
session version 2 is experimental to start trying breaking changes
type SessionV2Impl ¶
type SessionV2Impl struct { DefaultDepth int LoadStrategy LoadStrategy // contains filtered or unexported fields }
func (*SessionV2Impl) Close ¶
func (s *SessionV2Impl) Close() error
func (*SessionV2Impl) Delete ¶
func (s *SessionV2Impl) Delete(ctx context.Context, deleteObj interface{}) error
func (*SessionV2Impl) DeleteUUID ¶
func (s *SessionV2Impl) DeleteUUID(ctx context.Context, uuid string) error
func (*SessionV2Impl) Load ¶
func (s *SessionV2Impl) Load(ctx context.Context, respObj, id interface{}) error
func (*SessionV2Impl) LoadAll ¶
func (s *SessionV2Impl) LoadAll(ctx context.Context, respObj interface{}) error
func (*SessionV2Impl) LoadAllDepth ¶
func (s *SessionV2Impl) LoadAllDepth(ctx context.Context, respObj interface{}, depth int) error
func (*SessionV2Impl) LoadAllDepthFilter ¶
func (s *SessionV2Impl) LoadAllDepthFilter(ctx context.Context, respObj interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}) error
func (*SessionV2Impl) LoadAllDepthFilterPagination ¶
func (s *SessionV2Impl) LoadAllDepthFilterPagination(ctx context.Context, respObj interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error
func (*SessionV2Impl) LoadDepth ¶
func (s *SessionV2Impl) LoadDepth(ctx context.Context, respObj, id interface{}, depth int) error
func (*SessionV2Impl) LoadDepthFilter ¶
func (s *SessionV2Impl) LoadDepthFilter(ctx context.Context, respObj, id interface{}, depth int, filter *dsl.ConditionBuilder, params map[string]interface{}) error
func (*SessionV2Impl) LoadDepthFilterPagination ¶
func (s *SessionV2Impl) LoadDepthFilterPagination(ctx context.Context, respObj, id interface{}, depth int, filter dsl.ConditionOperator, params map[string]interface{}, pagination *Pagination) error
func (*SessionV2Impl) ManagedTransaction ¶
func (s *SessionV2Impl) ManagedTransaction(ctx context.Context, work TransactionWork) error
func (*SessionV2Impl) QueryRaw ¶
func (s *SessionV2Impl) QueryRaw(ctx context.Context, query string, properties map[string]interface{}) ([][]interface{}, neo4j.ResultSummary, error)
func (*SessionV2Impl) RollbackWithError ¶
func (s *SessionV2Impl) RollbackWithError(ctx context.Context, originalError error) error
type TransactionV2 ¶
type TransactionV2 interface { // Rollback rolls back transaction Rollback(ctx context.Context) error // RollbackWithError wraps original error into rollback error if there is one RollbackWithError(ctx context.Context, err error) error // Commit commits transaction Commit(ctx context.Context) error // contains filtered or unexported methods }
TransactionV2 specifies functions for Neo4j ACID transactions
type TransactionWork ¶
type TransactionWork func(tx TransactionV2) error
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
gogmcli/gen
gen provides code to generate link and unlink functions for gogm structs
|
gen provides code to generate link and unlink functions for gogm structs |
Code generated by GoGM v1.0.1.
|
Code generated by GoGM v1.0.1. |