Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

288
Visualizações
Neo4j - passing string parameters through JavaScript driver doesn't work

I am during the process of rewriting queries with already injected values to passing query and params object.

Queries which use ints work fine (I need to use neo4j's int translation):

...
ID(node)=$nodeId
...
LIMIT $fetchLimit
import { int } from 'neo4j-driver'
...
params = {
  nodeId: int(nodeId)
  fetchLimit: int(fetchLimit)
}

In some queries I am searching for strings and I am not using "normal" string search

WHERE node.property=$value       <-- "normal" search
WHERE node.property=~"$value.*"  <-- my search

Passing parameters doesn't work in this case.

I have a feeling that when I pass value: 'foo', neo4j resolves it as below:

WHERE node.property=~"$value.*"
...
value: 'foo'

*(injects parameters)*

WHERE node.property=~"'foo'.*"   <-- these inner quotation marks shouldn't be there

How to pass strings to this query and expect proper results?

(note that I am sure that query is written properly because when I directly inject parameters to query using JS's ${value}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can merge two strings with +. The regular expression after =~ is just a string.

So, working Cypher would be:

WHERE node.property =~ $value + ".*"

Alternatively, you could assemble the expression string in JavaScript:

search = 'foo'
params = {
  value: `${search}.*`
}
WHERE node.property =~ $value
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda