Skip to content

inthefabric/Weaver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Weaver

Weaver provides a fluent, strongly-typed interface for generating Gremlin scripts (for .NET/C#).

This requires that your graph domain classes use Weaver's custom attributes for vertices, edges, and properties. The Weaver.Titan package includes additional Titan-specific functionality for creating graph data-types, groups, and indices.

Install with NuGet

PM> Install-Package Weaver
PM> Install-Package Weaver.Titan 

Basic Usage

Weaver converts C# code:

myWeaverObj.Graph.V.ExactIndex<User>(x => x.Name, "Zach")

...into Gremlin script:

g.V('U_Na','Zach')

The Gremlin script can also be parameterized (enabled by default) to achieve more efficient query compilation on the database side.

Fabric Usage Example

Weaver was built to support the Fabric project, which provides several useful examples of Weaver configuration, setup, and usage.

A slightly-modified example from Fabric code:

IWeaverFuncAs<Member> memAlias;

IWeaverQuery q = myWeaverObj.Graph
	.V.ExactIndex<User>(x => x.ArtifactId, 123)
	.DefinesMemberList.ToMember
		.As(out memAlias)
	.InAppDefines.FromApp
		.Has(x => x.ArtifactId, WeaverStepHasOp.EqualTo, pApiCtx.AppId)
	.Back(memAlias)
	.HasMemberTypeAssign.ToMemberTypeAssign
		.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.None)
		.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.Invite)
		.Has(x => x.MemberTypeId, WeaverStepHasOp.NotEqualTo, (byte)MemberTypeId.Request)
	.Back(memAlias)
	.ToQuery();

SendGremlinRequest(q.Script, q.Params);

Gremlin Table Support

Weaver provides support for the Gremlin table step. Table columns are defined using Weaver's AsColumn() step, which support property-selection and customized scripts. Weaver's Table() step automatically builds the column clousures using the information provided in the AsColumn() steps.

For more details, see the Weaver Table Support wiki page.

Titan-Specific Functionality

As of build 0.5.2, Weaver.Titan project provides a variety of functionality that is specific to Titan. This includes:

  • Extended Property attribute to support standard, elastic, and vertex-centric indexing
  • Extended Edge attribute to support IN- and OUT-uniqueness
  • Creating Type Groups
  • Creating Property Keys using data from Property attributes
  • Creating Edge Labels using data from Property and Edge attributes
  • Automatic inclusion of vertex-centric index properties when adding new edges, using data from Property and Edge attributes
  • Forming queries using ElasticSearch indexes
  • Performing strongly-typed "Has" queries against vertex-centric edge properties

Graph of the Gods

In the Weaver.Examples project, the "Graph of the Gods" graph schema is implemented using Weaver's attributes, and some basic traversals are demonstrated. View the code.

githalytics.com alpha

About

A fluent, strongly-typed Gremlin script generator (for .NET/C#).

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages