neo4j-client in C, raw type encoding in a statement (i.e. int)

104 Views Asked by At

How can I send a statement with an integer type in neo4j-client? Fore example, in CREATE (n:Node {id:1}) the value of the field id is 1. Also, how can I retrieve it?

I have tried, assuming:

std::stringstream ss;
neo4j_run(connection,
            ss.str().c_str(), neo4j_null);

--

ss << "RETURN 'hello world'"; // server returns 'hello world'
ss << "RETURN 1"; // server returns 1
ss << "CREATE (n:Node {id:" << std::to_string(2) << "}); // Statement failed
ss << "CREATE (n:Node {id:" << neo4j_int(2) << "})"; // compile error

I am also printing those strings in the console, and CREATE (n:Node {id:" << std::to_string(2) << "}) copy-pasted fro the consolo to the web gui works.

1

There are 1 best solutions below

0
On

You're probably best sending the integer ID as a parameter, e.g.:

neo4j_map_entry_t map_entry = neo4j_map_entry("id", 2);
neo4j_value_t params = neo4j_map(&map_entry, 1);
neo4j_run(session, "CREATE (n:Node {id:$id});", params);