Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-16-2022 11:23 AM
Hello,
While playing with queries using Neo4j Browser, sometimes is helpful to set query parameters in advance so those variables can be easily changed without modifying the query itself. I could do that with simple parameters or even maps:
:param {
personName: "Val Kilmer",
movieTitle: "Top Gun"
}
But, when I try to nest maps inside a list like the below I get a syntax error:
:param items => [
{
personName: "Val Kilmer",
movieTitle: "Top Gun"
},
{
personName: "Tom Cruise",
movieTitle: "Top Gun"
}
]
// Returns
Syntax error at line 2 col 0:
{
^
Unexpected "\n".
Funny enough, it works while running the command in a single-line way:
:param items => [{personName: "Val Kilmer", movieTitle: "Top Gun"}, {personName: "Tom Cruise", movieTitle: "Top Gun"}]
Although, whenever I need to set many query parameters, the single-line approach above lacks readability.
Does anyone how to set a list of maps using that ":param" command in a multiline way?
Thank you.
09-16-2022 12:14 PM
I don't know, but you could author the json in a json formatter (online or locally) and format to 'minify' or 'compact' format and paste the single line in the browser. It renders nice if you return the parameters with ':params'
09-21-2022 09:56 AM
I've just find a way:
:param {
items: [
{
personName: "Val Kilmer",
movieTitle: "Top Gun"
},
{
personName: "Tom Cruise",
movieTitle: "Top Gun"
}
]
}
@glilienfield thank you for your tip, but I was trying to avoid additional steps for this specific workflow I am working on.
All the sessions of the conference are now available online