Skip to content

MarneeDear/Neo4jTypeProvider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Neo4jTypeProvider

This is a fork of the original Neo4j Type Provider by Pete Bayne on BitBucket.

Original Neo4j Type Provider blog post

I forked it and made some changes to make it work with v. 3 of Neo4j. See my blog post:

Neo4j Type Provider blog post

Example Usage

First you need to instantiate the type like this.

    [<Literal>]
    let ConnectionString = @"http://localhost:7474/db/data" //the db should be populated
    type IVRSchema = Haumohio.Neo4j.Schema< ConnectionString >

You can get at your graphs labels like this (see my previous post on the IVR graph).

let startLabel = IVRSchema.Labels.START

You can get at a label's property fields like this.

let endIdField = IVRSchema.Props.END.id

You can get at a relationship like this.

let successRelationship = IVRSchema.Rels.SUCCESS

You can get a node as an object like this.

let entryNode = IVRSchema.Proxies.ENTRY

Putting it all together you can do something like this to get a list of related nodes. In this case the path is from an entry node to the next entry node through the success relationship. Here I am using Neo4jClient.

type IVRSchema = Haumohio.Neo4j.Schema< ConnectionString >
let db = new Neo4jClient.GraphClient(Uri(ConnectionString))
db.Connect()

let data = 
    db.Cypher
        .Match(sprintf "(s:%s)-[r:%s]->(e:%s)" IVRSchema.Labels.START IVRSchema.Rels.GOTO IVRSchema.Labels.ENTRY)
        .Return(fun (s:ICypherResultItem) (e:ICypherResultItem) -> (s.As<IVRSchema.Proxies.START>(), e.As<IVRSchema.Proxies.ENTRY>()))
        .Results

let sNode, eNode = data |> Seq.head

Thoughts

This is a nice way to work with your database's schema and it will naturally update as the source database changes.

I |> heart TypeProviders

Releases

No releases published

Packages

No packages published

Languages