Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce resultTransformer.first #1200

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

bigmontz
Copy link
Contributor

⚠️ This API is released as preview.
This function enables fetching only the first record in the Result. If any other record is present, it will be discarded and network optimization might be applied.

Examples:

// using in the execute query
const maybeFirstRecord = await driver.executeQuery('MATCH (p:Person{ age: $age }) RETURN p.name as name', { age: 25 }, {
    database: 'neo4j,
    resultTransformer: neo4j.resultTransformers.first()
})
// using in other a result

const maybeFirstRecord = await session.executeRead(tx => {
    // do not `await` or `resolve` the result before send it to the transformer
    const result = tx.run('MATCH (p:Person{ age: $age }) RETURN p.name as name', { age: 25 })
    return  neo4j.resultTransformers.first()(result)
})

⚠️ This API is released as preview.

**⚠️ This API is released as preview.**
This function enables fetching only the first record in the Result.
If any other record is present, it will be discarded and network optimization might be applied.

Examples:

```javascript
// using in the execute query
const maybeFirstRecord = await driver.executeQuery('MATCH (p:Person{ age: $age }) RETURN p.name as name', { age: 25 }, {
    database: 'neo4j,
    resultTransformer: neo4j.resultTransformers.first()
})
```

```javascript
// using in other a result

const maybeFirstRecord = await session.executeRead(tx => {
    // do not `await` or `resolve` the result before send it to the transformer
    const result = tx.run('MATCH (p:Person{ age: $age }) RETURN p.name as name', { age: 25 })
    return  neo4j.resultTransformers.first()(result)
})
```

**⚠️ This API is released as preview.**
Copy link

@RichardIrons-neo4j RichardIrons-neo4j left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good.

@bigmontz bigmontz merged commit 22019bb into neo4j:5.0 Jun 19, 2024
37 checks passed
@bigmontz bigmontz deleted the 5.22/feature/result-transformer-first branch June 19, 2024 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants