All Projects β†’ OKTAYKIR β†’ NeoClient

OKTAYKIR / NeoClient

Licence: MIT license
πŸ¦‰ Lightweight OGM for Neo4j which support transactions and BOLT protocol.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to NeoClient

Neo4j
Graphs for Everyone
Stars: ✭ 9,582 (+45528.57%)
Mutual labels:  neo4j, nosql, graph-database, graphdb, cypher
Public-Transport-SP-Graph-Database
Metropolitan Transport Network from SΓ£o Paulo mapped in a NoSQL graph database.
Stars: ✭ 25 (+19.05%)
Mutual labels:  neo4j, nosql, graph-database, cypher
Redisgraph
A graph database as a Redis module
Stars: ✭ 1,292 (+6052.38%)
Mutual labels:  nosql, graph-database, graphdb, cypher
OGMNeo
[No Maintenance] Neo4j nodeJS OGM(object-graph mapping) abstraction layer
Stars: ✭ 54 (+157.14%)
Mutual labels:  neo4j, bolt, cypher, ogm-neo4j
seabolt
Neo4j Bolt Connector for C
Stars: ✭ 37 (+76.19%)
Mutual labels:  neo4j, graph-database, cypher, cypher-query
Movies Java Bolt
Neo4j Movies Example application with SparkJava backend using the neo4j-java-driver
Stars: ✭ 66 (+214.29%)
Mutual labels:  neo4j, graph-database, cypher
R2d2 Cypher
Cypher support for the r2d2 connection pool
Stars: ✭ 8 (-61.9%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j sips
Elixir driver for the Neo4j graph database server
Stars: ✭ 78 (+271.43%)
Mutual labels:  neo4j, graph-database, graphdb
Neo4j Etl
Data import from relational databases to Neo4j.
Stars: ✭ 165 (+685.71%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j Graph Algorithms
Efficient Graph Algorithms for Neo4j
Stars: ✭ 713 (+3295.24%)
Mutual labels:  neo4j, graph-database, cypher
Movies Javascript Bolt
Neo4j Movies Example with webpack-in-browser app using the neo4j-javascript-driver
Stars: ✭ 123 (+485.71%)
Mutual labels:  neo4j, graph-database, cypher
Movies Python Bolt
Neo4j Movies Example application with Flask backend using the neo4j-python-driver
Stars: ✭ 197 (+838.1%)
Mutual labels:  neo4j, graph-database, cypher
Neo4j Tableau
Neo4j Tableau Integration via WDC
Stars: ✭ 56 (+166.67%)
Mutual labels:  neo4j, graph-database, cypher
neo4j-faker
Use faker cypher functions to generate demo and test data with cypher
Stars: ✭ 30 (+42.86%)
Mutual labels:  neo4j, graph-database, cypher
Helicalinsight
Helical Insight software is world’s first Open Source Business Intelligence framework which helps you to make sense out of your data and make well informed decisions.
Stars: ✭ 214 (+919.05%)
Mutual labels:  neo4j, nosql, graph-database
docs
Source code of the ArangoDB online documentation
Stars: ✭ 18 (-14.29%)
Mutual labels:  nosql, graph-database, graphdb
Neo4j 3d Force Graph
Experiments with Neo4j & 3d-force-graph https://github.com/vasturiano/3d-force-graph
Stars: ✭ 159 (+657.14%)
Mutual labels:  neo4j, graph-database, cypher
ml-models
Machine Learning Procedures and Functions for Neo4j
Stars: ✭ 63 (+200%)
Mutual labels:  neo4j, graph-database, cypher
neo4rs
Neo4j driver for rust
Stars: ✭ 41 (+95.24%)
Mutual labels:  neo4j, bolt, cypher
Neo4j Python Driver
Neo4j Bolt driver for Python
Stars: ✭ 607 (+2790.48%)
Mutual labels:  neo4j, graph-database, cypher

NeoClient logo

NeoClient

Hits GitHub issues Build Status PRs Welcome nuget

A Lightweight and simple object graph mapper (OGM) for Neo4j which support transactions and BOLT protocol.

πŸ“¦ Installation

NeoClient is available on NuGet.

dotnet add package NeoClient

Examples

  • NeoClient: Neo4j Movies Example Application - Asp.net WebApi Version

πŸš€ Usage

Creating Database Connection

Optional you can pass authentication credential via the constructor.

INeoClient client = new NeoClient(
    uri: "bolt://localhost:7687", 
    userName: "user", //optional
    password: "password", //optional
    config: Config.Builder //optional
        .WithMaxConnectionLifetime(TimeSpan.FromMinutes(30))
        .WithMaxConnectionPoolSize(100)
        .WithConnectionAcquisitionTimeout(TimeSpan.FromMinutes(2))
        .WithEncryptionLevel(EncryptionLevel.None)
        .ToConfig() 
    strip_hyphens: true //optional, default is false
);
client.Connect();

For example, if you were using any IoC container, you could register the client like so:

container.Register<INeoClient>((c, p) =>
{
    INeoClient client = new NeoClient(
        uri: "bolt://localhost:7687", 
        ...
        );
    client.Connect();
    return client;
});

User Node Model

 public class User : EntityBase
 {
     public User() : base(label: "User") { }
     
     public string FirstName { get; set; }
     public string LastName { get; set; }
     public string Email { get; set; }
 }

Creating a Node

User entity = client.Add(new User { Email = "[email protected]", FirstName = "Oktay", LastName = "Kir" });

Adding a Label to a Node

bool result = client.AddLabel(
    uuid: "01a68df3-cc35-4eb0-a199-0d924da86eab",
    labelName: @"LabelName"
);

Retrieving a Node by Id

User node = client.GetByUuidWithRelatedNodes<User>("01a68df3-cc35-4eb0-a199-0d924da86eab");

Retrieving All Nodes

IList<User> nodes = client.GetAll<User>();

Retrieving Nodes by Single Property

IList<User> nodes = client.GetByProperty<User>("Email", "[email protected]");

Retrieving Nodes by Multiple Properties

var properties = new Dictionary<string, object>(){
	{ nameof(User.Name), "keanu"},
};

IList<User> nodes = client.GetByProperties<User>(properties);

Updating a Node

User updatedNode = client.Update(
    entity: node,
    uuid: "01a68df3-cc35-4eb0-a199-0d924da86eab",
    fetchResult: true //optional, default is false
);

Deleting a Node (Soft Delete)

User node = client.Delete<User>("01a68df3-cc35-4eb0-a199-0d924da86eab");

Dropping a Node by Id

bool result = client.Drop<User>("01a68df3-cc35-4eb0-a199-0d924da86eab");

Drop Nodes by Properties

int nodesDeleted = client.DropByProperties<User>(
    props: new Dictionary<string, object>(){
        { nameof(User.Name), "keanu"},
    }
);

Create a Relationship Between Certain Two Nodes

bool isCreated = client.CreateRelationship(
    uuidFrom: "2ac55031-3089-453a-a858-e1a9a8b68a16",
    uuidTo: "ac43523a-a15e-4d25-876e-e2a2cc4de125",
    relationshipAttribute: new RelationshipAttribute{
        Direction = DIRECTION.INCOMING,
        Name = "FAMILY"
    },
    props: new Dictionary<string, object>(){ //optional
        {"CreatedAt", DateTime.UtcNow},
        {"Kinship_Level", 1},
	    {"Name", "FakeName"}
    }
);

Dropping a Relationship Between Certain Two Nodes

bool result = client.DropRelationshipBetweenTwoNodes(
    uuidFrom: "2ac55031-3089-453a-a858-e1a9a8b68a16",
    uuidTo: "ac43523a-a15e-4d25-876e-e2a2cc4de125",
    relationshipAttribute: node.GetRelationshipAttributes(ep => ep.roles).FirstOrDefault()
);

Merge Nodes

Creating a node with its properties on creation time. If the nodes had already been found, different multiple properties would have been set.

User node = client.Merge(
    entityOnCreate: new User(){ name = "keanu"; createdAt = DateTime.UtcNow.ToTimeStamp(); },
    entityOnUpdate: new User(){ name = "keanu"; updatedAt = DateTime.UtcNow.ToTimeStamp(); },
    where: "name:\"keanu\""
);

Merge Relationships

bool result = client.MergeRelationship(
    uuidFrom: "2ac55031-3089-453a-a858-e1a9a8b68a16",
    uuidTo: "ac43523a-a15e-4d25-876e-e2a2cc4de125",
    relationshipAttribute: node.GetRelationshipAttributes(ep => ep.roles).FirstOrDefault()
);

Running Custom Cypher Query

Example 1:

string cypherCreateQuery = @"CREATE (Neo:Crew {name:'Neo'}), 
    (Morpheus:Crew {name: 'Morpheus'}), 
    (Trinity:Crew {name: 'Trinity'}), 
    (Cypher:Crew:Matrix {name: 'Cypher'}), 
    (Smith:Matrix {name: 'Agent Smith'}), 
    (Architect:Matrix {name:'The Architect'}),
    (Neo)-[:KNOWS]->(Morpheus), 
    (Neo)-[:LOVES]->(Trinity), 
    (Morpheus)-[:KNOWS]->(Trinity),
    (Morpheus)-[:KNOWS]->(Cypher), 
    (Cypher)-[:KNOWS]->(Smith), 
    (Smith)-[:CODED_BY]->(Architect)";

IStatementResult result = client.RunCustomQuery(query: cypherQuery);

string cypherQuery = @"MATCH (n:Crew)-[r:KNOWS*]-(m) WHERE n.name='Neo' RETURN n AS Neo,r,m";

IStatementResult queryResult = client.RunCustomQuery(query: cypherQuery);
IList<object> result = queryResult.GetValues();

Example 2:

string cypherQuery = @"MATCH (n:User) RETURN n";

IList<User> result = client.RunCustomQuery<User>(query: cypherQuery);

Integration Tests

NeoClient has several tests that verify that its ability to use the system it integrates with correctly.

There's a docker-compose file and you can use the following command to launch Neo4j container for running the integration tests.

$ docker-compose up -d

Transactions

To Do

  • Nuget package
  • Integration Tests
  • Creating example projects
  • Supporting more functionalities

🀝 Contributing

  1. Fork it ( https://github.com/OKTAYKIR/NeoClient/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

✨ Contributors

GitHub Contributors Image

Show your support

Please ⭐️ this repository if this project helped you!

πŸ“ License

MIT license

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].