Search code examples
neo4jneo4j-apoc

how to access neo4j apoc uuid as a string?


I am trying to use apoc.create.uuid() in nodejs for the first time. In the neo4j browser I can see that the result is a string like this:

"a1d0d202-b585-4130-ba96-4c75ca4860ca"

...but in node it appears as:

"\ta1d0d202-b585-4130-ba96-4c75ca4860ca"

this is the cypher query:

MATCH (r:Race {race_id: $race_id})
WITH r 
MATCH (m:Member)-[v:HAS_VOTED]->(b)-[vr:FOR_RACE]->(r)
RETURN {votes:v.voter_choice}

console.log(JSON.stringify(result.records[0])) produces: [[{"votes":"\ta1d0d202-b585-4130-ba96-4c75ca4860ca"},{"votes":"\ta1d0d202-b585-4130-ba96-4c75ca4860ca"},{"votes":"\ta1d0d202-b585-4130-ba96-4c75ca4860ca"},{"votes":"\ta1d0d202-b585-4130-ba96-4c75ca4860ca"},{"votes":"bd607ccd-85be-4b78-9d6e-89cbbb087d01"},{"votes":"bd607ccd-85be-4b78-9d6e-89cbbb087d01"},{"votes":"bd607ccd-85be-4b78-9d6e-89cbbb087d01"},{"votes":"bd607ccd-85be-4b78-9d6e-89cbbb087d01"},{"votes":"bd607ccd-85be-4b78-9d6e-89cbbb087d01"}]].

This is also not consistent across all return values...not all has this extra 2 leading characters. I am really not sure what causes this but I need these values to be consistent for comparison purposes. Can anyone explain what is going on here?

EDIT: DB data: m.member_id v.voter_choice b.box_id "a1d0d202-b585-4130-ba96-4c75ca4860ca" " a1d0d202-b585-4130-ba96-4c75ca4860ca" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "bbdbdff7-a178-479c-9dc7-894642365ca9" " a1d0d202-b585-4130-ba96-4c75ca4860ca" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "57f81764-9a1e-4c02-bdd7-875e5e741471" " a1d0d202-b585-4130-ba96-4c75ca4860ca" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "6417c1f8-646d-49e1-9ec3-e105f33637ae" " a1d0d202-b585-4130-ba96-4c75ca4860ca" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "7417f023-b1a9-4535-93a3-7a001305ccb7" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "a0ea2113-63d8-4cde-a4e8-1ab20e3637f9" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "ac913fcc-8070-4738-8946-c32ab7531446" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "009d5129-a62c-49d7-aa4c-5ec9a8b01720" "66514ccf-8808-4649-88b3-42f9db26616f" "bd607ccd-85be-4b78-9d6e-89cbbb087d01" "009d5129-a62c-49d7-aa4c-5ec9a8b01720"

I think I may have found the answer......in posting the edit above I noticed that the errant string has a leading space. I think this is the cause of the leading '\ta.....' let me know if you agree.


Solution

  • the problem exists in neo4j browser...if you cut the uuid value from the side window and paste it in the query window a leading space is added to the uuid string...not sure why....so just delete the leading space(s) before running the query.