But not all companies have a cessation day because they are operative...
Company 1 is still operative:
{
"company_number": 001,
"number_of_employees": 450
"company status": "OPERATIVE"
"date_of_creation": 01/02/1968
"date_of_cessation": date (It doesn't have a cessation date)
}
Company 2 is no longer operative:
{
"company_number": 002,
"number_of_employees": 500
"company status": "NO OPERATIVE"
"date_of_creation": 01/02/1970
"date_of_cessation":01/02/2022
}
I would like to know If Neo4j allows me to upload these types of JSON documents by using the Cypher query. I don't want that Cypher query fails because date_of_cessation doesn't exist in some documents.
You could implement some conditional logic leveraging a 'call' subquery. The syntax is like the following. Insert this in your code for each property that you want to conditionally process that may be null. The need for the double 'with' statement is that the query parser will complain that a 'with' in a call subquery has to be simple. To get around this, a second one is added that supports the 'where' clause.
call {
with row
with row
where row.property is not null
//do something
//you can not return a value though
}
You could implement conditional logic using apoc methods. Use the do.when() or do.case() methods when the query needs to write to the database.