I want to create object and get it in JSON format along with its ID in the format.
Suppose I create object like this:
CREATE (task3:TASK {idesc: 'Task 3', status: 'new', due_date: date("2020-06-16") })
The simplest query
MATCH (n) RETURN n
This returns a too complex nested structure. What I want is just the object I created above in JSON with auto-generated ID also as a parameter. Anyway, I peeked deep inside the nesting to find "records" and then "properties" of each element which is closest to what I want. Here is what I get:
{due_date: n, status: "pending", desc: "Task 1"}
This has 2 problems: I want due_date in UTC string format. I also want the ID of the object returned in an ID property.
Question 1) Is there an easy way to get what I want?
Question 2) I tried coding this query to get the id:
MATCH (n) RETURN {id:ID(n), desc: n.desc, status: n.status, due_date:n.due_date}
But here ID does not work and gives error: This record has no field with key 'n'.
If I do just
MATCH (n) RETURN ID(n)
Then ID works without problem. Why doesn't it work inside the earlier expression?
Thanks.