Search code examples
.netf#neo4jneo4jclient

Create node with label using Neo4jClient in f#


I am trying to create a node and also assign a label to that node. Following the instructions in Using Neo4j Graph DB With F#, I managed to create the Person nodes, but I could not create a label Person for the node created. Is my use of the create method wrong? Do I need to pass it as a parameter? Could I use the Cypher create instead of create?


Solution

  • The example uses the old API based way of using 'Create' so you used to do:

    client.Create person
    

    now you can (and should) use the Cypher version:

    let createPerson person =
        client.Cypher
            .Create("(p:Person {param})")
            .WithParam("param", person)
            .Return<Person>("p")
            .Results
            .Single();
    
    let pA = createPerson { Name = "PersonA"; Twitter = "tA" }
    

    And you should be passing in the person as a parameter. Using the Cypher version is the only way to get labels into your db.