Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

225
Views
Retrieving all neo4j <Record> keys data without using .get()

I am using neo4j-driver in order to run my query:

import neo4j from "neo4j-driver";

const driver = neo4j.driver(
  process.env.NEO4J_URI,
  neo4j.auth.basic(process.env.NEO4J_USER, process.env.NEO4J_PASS)
);

export const session = driver.session();

When I retrieve the results, I now have to map trough all of the records and retrieve all the values in order to format the data that is otherwise in the _fields property. Is there a way to do this inside the DB query, or without using separate .get calls. I am worried about performance, since the number of nodes will be be big, and mapping trough them could burn unnecessary resources.

export const getColorsList = async (): Promise<Color[]> => {
  const readQuery = `
    MATCH (c:Color)-[a:ASSOCIATED_WITH]->(t:Tag)
    WITH COLLECT(t.name) AS tags, c
    RETURN  c.alternativeNames AS alternativeNames, c.hex AS hex, c.name AS name, c.temperature AS temperature, tags AS tags
  `;
  const readResult = await session.readTransaction((tx) => tx.run(readQuery));

  const colors: Color[] = readResult.records.map((color) => {
    const alternativeNames = color.get("alternativeNames");
    const hex = color.get("hex");
    const name = color.get("name");
    const temperature = color.get("temperature");
    const tags = color.get("tags");
    return {
      alternativeNames,
      hex,
      name,
      temperature,
      tags,
    };
  });

  return colors;
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can try using a map projection in your query, something like this:

MATCH (c:Color)-[a:ASSOCIATED_WITH]->(t:Tag) WITH COLLECT(t.name) AS tags, c RETURN c{.alternativeNames, .hex, .name, .temperature, tags: tags}

Here's the link to the documentation.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!