Documentation
¶
Index ¶
- Variables
- func Create[T any](db *GremlinDriver, value *T) error
- func GetLabel[T any]() string
- func Save[T any](driver *GremlinDriver, v *T) error
- func SliceToAnySlice[T any](slice []T) []any
- func ToMapTraversal(query *gremlingo.GraphTraversal, ...) *gremlingo.GraphTraversal
- func UnloadGremlinResultIntoStruct(v any, result *gremlingo.Result) error
- type AfterCreateHook
- type AfterFindHook
- type AfterUpdateHook
- type BeforeCreateHook
- type BeforeUpdateHook
- type Config
- type DatabaseDriver
- type GremlinDriver
- type GremlinOrder
- type OrderCondition
- type Query
- func (q *Query[T]) AddSubTraversal(gremlinTag string, traversal *gremlingo.GraphTraversal) *Query[T]
- func (q *Query[T]) AddSubTraversals(subTraversals map[string]*gremlingo.GraphTraversal) *Query[T]
- func (q *Query[T]) BuildQuery() *gremlingo.GraphTraversal
- func (q *Query[T]) Count() (int, error)
- func (q *Query[T]) Dedup() *Query[T]
- func (q *Query[T]) Delete() error
- func (q *Query[T]) Find() ([]T, error)
- func (q *Query[T]) ID(id any) (T, error)
- func (q *Query[T]) IDs(id ...any) *Query[T]
- func (q *Query[T]) Labels(labels ...string) *Query[T]
- func (q *Query[T]) Limit(limit int) *Query[T]
- func (q *Query[T]) Offset(offset int) *Query[T]
- func (q *Query[T]) OrderBy(field string, order GremlinOrder) *Query[T]
- func (q *Query[T]) PreQuery(traversal *gremlingo.GraphTraversal) *Query[T]
- func (q *Query[T]) Range(lower int, upper int) *Query[T]
- func (q *Query[T]) Select(fields ...string) *Query[T]
- func (q *Query[T]) Take() (T, error)
- func (q *Query[T]) Update(propertyName string, value any) error
- func (q *Query[T]) Where(field string, operator comparator.Comparator, value any) *Query[T]
- func (q *Query[T]) WhereTraversal(traversal *gremlingo.GraphTraversal) *Query[T]
- type QueryCondition
- type QueryOpts
- type RangeCondition
- type RawQuery
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Create ¶
func Create[T any](db *GremlinDriver, value *T) error
func Save ¶
func Save[T any](driver *GremlinDriver, v *T) error
func SliceToAnySlice ¶ added in v0.3.6
func ToMapTraversal ¶ added in v0.2.0
func ToMapTraversal( query *gremlingo.GraphTraversal, subtraversals map[string]*gremlingo.GraphTraversal, args ...any, ) *gremlingo.GraphTraversal
ToMapTraversal converts a Gremlin traversal to a map traversal using valuemap and projecting the subtraversals if there are no subtraversals, it will return the query.ValueMap(args...).By(
anonymousTraversal.Choose( anonymousTraversal.Count(Scope.Local).Is(P.Eq(1)), anonymousTraversal.Unfold(), anonymousTraversal.Identity(), ), )
func UnloadGremlinResultIntoStruct ¶ added in v0.1.3
UnloadGremlinResultIntoStruct unloads a gremlin result into a struct it will recursively unload the result into the struct v any must be a pointer to a struct result *gremlingo.Result is the gremlin result to unload which must be a map note the struct must have gremlin tags on the fields to be unloaded
Types ¶
type AfterCreateHook ¶ added in v0.2.11
type AfterCreateHook interface {
AfterCreate(db *GremlinDriver) error
}
AfterCreateHook runs after create persists the vertex. Returning an error propagates to the caller.
type AfterFindHook ¶ added in v0.2.12
type AfterFindHook interface {
AfterFind(db *GremlinDriver) error
}
AfterFindHook runs after a vertex has been loaded from the database. Returning an error propagates to the caller.
type AfterUpdateHook ¶ added in v0.2.11
type AfterUpdateHook interface {
AfterUpdate(db *GremlinDriver) error
}
AfterUpdateHook runs after update persists the vertex. Returning an error propagates to the caller.
type BeforeCreateHook ¶ added in v0.2.11
type BeforeCreateHook interface {
BeforeCreate(db *GremlinDriver) error
}
BeforeCreateHook runs before create persists the vertex. Returning an error aborts the create.
type BeforeUpdateHook ¶ added in v0.2.11
type BeforeUpdateHook interface {
BeforeUpdate(db *GremlinDriver) error
}
BeforeUpdateHook runs before update persists the vertex. Returning an error aborts the update.
type Config ¶ added in v0.3.1
type Config struct {
Driver DatabaseDriver
IDGenerator func() any
GremlinConnectionSettings func(settings *gremlingo.DriverRemoteConnectionSettings)
}
type DatabaseDriver ¶ added in v0.1.0
type DatabaseDriver string
const ( Gremlin DatabaseDriver = "gremlin" Neptune DatabaseDriver = "neptune" )
type GremlinDriver ¶
type GremlinDriver struct {
// contains filtered or unexported fields
}
func (*GremlinDriver) Close ¶
func (driver *GremlinDriver) Close()
func (*GremlinDriver) G ¶ added in v0.2.10
func (driver *GremlinDriver) G() *gremlingo.GraphTraversalSource
G exposes the traversal source for building custom traversals.
func (*GremlinDriver) Label ¶
func (driver *GremlinDriver) Label(label string) *RawQuery
Label returns a query builder for a specific label
type OrderCondition ¶
type OrderCondition struct {
// contains filtered or unexported fields
}
type Query ¶
type Query[T any] struct { // contains filtered or unexported fields }
Query represents a chainable query builder
func Model ¶
func Model[T any](driver *GremlinDriver) *Query[T]
Model returns a new query builder for the specified type
func NewQuery ¶
func NewQuery[T any](db *GremlinDriver) *Query[T]
NewQuery creates a new query builder for type T
func Where ¶
func Where[T any]( driver *GremlinDriver, field string, operator comparator.Comparator, value any, ) *Query[T]
Where is a convenience method that creates a new query with a condition
func (*Query[T]) AddSubTraversal ¶ added in v0.2.0
func (q *Query[T]) AddSubTraversal( gremlinTag string, traversal *gremlingo.GraphTraversal, ) *Query[T]
AddSubTraversal adds a single subtraversal to the query This is useful when you need to fetch related data or perform complex traversals that should populate a specific field in your struct. You will need to signal this in your struct tags with the gremlinSubTraversal tag.
func (*Query[T]) AddSubTraversals ¶ added in v0.2.0
func (q *Query[T]) AddSubTraversals(subTraversals map[string]*gremlingo.GraphTraversal) *Query[T]
AddSubTraversals adds multiple subtraversals to the query This is useful when you need to fetch related data or perform complex traversals that should populate specific fields in your struct. You will need to signal this in your struct tags with the gremlinSubTraversal tag.
func (*Query[T]) BuildQuery ¶ added in v0.1.3
func (q *Query[T]) BuildQuery() *gremlingo.GraphTraversal
BuildQuery constructs the Gremlin traversal from the query conditions
func (*Query[T]) ID ¶ added in v0.1.0
ID finds vertex by id in a more optimized way than using where
func (*Query[T]) IDs ¶ added in v0.1.3
IDs adds the ids to the query You can use this to speed up the query by using the graph index
func (*Query[T]) Labels ¶ added in v0.3.6
Labels adds labels to the query This is useful when you need to filter by multiple labels You can use this to speed up the query by using the graph index Note this will override any label set via the Label() method or pre computed label
func (*Query[T]) OrderBy ¶
func (q *Query[T]) OrderBy(field string, order GremlinOrder) *Query[T]
OrderBy adds ordering to the query
func (*Query[T]) PreQuery ¶ added in v0.2.10
func (q *Query[T]) PreQuery(traversal *gremlingo.GraphTraversal) *Query[T]
PreQuery sets a traversal to run before applying query conditions. When set, it replaces the default V() start for the query.
func (*Query[T]) Range ¶ added in v0.2.8
Range sets the range of the query This is useful when you need to get a range of results It will be ignored if offset is set Note the range is inclusive of lower bound and exclusive of upper bound Examples:
- Range(0, 10) will return results 0-9
- Range(10, 20) will return results 10-19
- Range(0, 20) will return results 0-19
func (*Query[T]) Update ¶
Update updates a property of the struct NOTE: Slices will be updated as Cardinality.Set NOTE: Maps will be updated as Cardinality.Set with keys as the value of the property
func (*Query[T]) Where ¶
func (q *Query[T]) Where(field string, operator comparator.Comparator, value any) *Query[T]
Where adds a condition to the query
func (*Query[T]) WhereTraversal ¶
func (q *Query[T]) WhereTraversal(traversal *gremlingo.GraphTraversal) *Query[T]
WhereTraversal adds a custom Gremlin traversal condition
type QueryCondition ¶
type QueryCondition struct {
// contains filtered or unexported fields
}
func (*QueryCondition) String ¶ added in v0.1.0
func (qc *QueryCondition) String() string
type QueryOpts ¶
type QueryOpts struct {
ID any
Where *gremlingo.GraphTraversal
}
type RangeCondition ¶ added in v0.2.8
type RangeCondition struct {
// contains filtered or unexported fields
}