Hi,
I'm having an issue with using the driver for neo4j in C.
I have a query which returns a collection without keys, also called a list (or an array).
I'm trying to iterate over its fields in order to parse it to another output of my choice but that didn't work out.
This is the query:
MATCH (i:Inode)
WHERE i.ino=2 AND i.fsid=1
MATCH p = (i)-[:IN_DIR*]->(:Inode {ino: 0})
UNWIND nodes(p) as nlist
WITH collect(nlist.name) as pathNames
RETURN pathNames, size(pathNames) as listSize;
The result array i'm getting is array of strings (names without special chars).
By the looks of the API, I need to retrieve any field and then consuming it with basic knowledge of its type. This is my C code (after checking the transaction was successful):
// fetch collection as a list(an ordered list of elements containing the names of dirs in destination path)
neo4j_value_t value_list = neo4j_result_field(result, 0);
// fetch the list's length from the other returned field of the query specified for this functionality
neo4j_value_t value_list_len = neo4j_result_field(result, 1);
long long list_len_res = neo4j_int_value(value_list_len);
if(list_len_res == 0) {
// list is empty -> no result found (though query returned with success)
return -1;
}
// parse the value of the list as a list that has reachable elements
neo4j_value_t list = neo4j_list(&value_list, list_len_res);
char tmp_buf[100];
for(int i = 0; i < list_len_res; ++i) {
neo4j_value_t elem = neo4j_list_get(list, i);
TEST_ASSERT(!neo4j_is_null(elem));
neo4j_tostring(elem, tmp_buf, sizeof(tmp_buf));
...(do stuff with tmp_buf)
}
But when I print insides of tmp_buf I get that:
- first iteration shows the whole array.
- second iteration shows a number (not a string that was in the array).
Any answer would help, thanks!