Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass multiple parameters to the Neo4j Browser

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.)

like image 406
Gabor Szarnyas Avatar asked Sep 16 '25 01:09

Gabor Szarnyas


1 Answers

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.

like image 162
cybersam Avatar answered Sep 19 '25 15:09

cybersam