4

I'd like to pass multiple parameters to the Neo4j 4.0 browser while making sure that the type of the parameter values (int, date) is interpreted correctly. I tried using the syntax of the Cypher shell commands:

  1. Using the colon syntax paramName: paramValue allows passing multiple parameters but their type is implicitly converted (date to string, integer to float):

    :param d: date('2020-03-07'), x: 1
    

    Result:

    {
      "d": "date('2020-03-07')",
      "x": 1.0
    }
    
  2. Using the arrow syntax, I can define the both parameters correctly but it requires separate :param commands:

    :param d => date('2020-03-07')
    :param x => 1
    :params
    

    Result:

    {
      "d": "2020-03-07",
      "x": 1
    }
    

Many of my queries use a large number of parameters -- it there a way to pass all parameters correctly using a single command?

(There is a related question, neo4j: What is the syntax to set cypher query parameters in the browser interface?, however, answers do not consider the issues regarding types.)

Gabor Szarnyas
  • 4,410
  • 3
  • 18
  • 42

1 Answers1

4

You can create multiple parameters with the correct types in a single :param command using "destructuring".

For example, to get d and x with the correct types:

:param [{d, x}] => {RETURN date('2020-03-07') AS d, 1 AS x}

Use the :help params command in the browser to get some more information.

cybersam
  • 63,203
  • 6
  • 53
  • 76