Skip to content

Database Notification Improvements #1064

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

Merged
merged 15 commits into from
Mar 17, 2023
Merged

Conversation

bigmontz
Copy link
Contributor

@bigmontz bigmontz commented Feb 28, 2023

Cypher are improving the notifications that are produced by query execution by making it configurable what level of notifications can be returned and adding additional information to notifications.

Usage:

import neo4j from 'neo4j-driver'

// Configuring at the driver level
const driver = neo4j.driver(<ADDRESS>, <TOKEN>, { 
    notificationFilter: {
       minimumSeverityLevel: neo4j.notificationFilterMinimumSeverityLevel.WARNING // or 'WARNING'
    }
})

// Configuring a the session level
const session = driver.session({
    database: 'neo4j',
    notificationFilter: {
       minimumSeverityLevel: neo4j.notificationFilterMinimumSeverityLevel.INFORMATION // or 'INFORMATION',
       disabledCategories: [
          neo4j.notificationFilterDisabledCategory.HINT, // or 'HINT',
          neo4j.notificationFilterDisabledCategory.GENERIC // or 'GENERIC'
       ]
    }
})

// Configuring using plain string.
const session = driver.session({
    database: 'neo4j',
    notificationFilter: {
       minimumSeverityLevel: 'INFORMATION',
       disabledCategories: [
         'HINT',
         'GENERIC'
       ]
    }
})


const { summary }  = await session.executeWrite(tx => tx.run(<QUERY>, <PARAMS>))

// Reading notifications
for (const notification of summary.notifications) {
     switch(notification.severityLevel) {
          case neo4j.notificationSeverityLevel.INFORMATION: // or simply 'INFORMATION'
              console.info(`[${notification.category}] ${notification.title} - ${notification.description}`)
              break
          case neo4j.notificationSeverityLevel.WARNING: // or simply 'WARNING'
              console.warn(`[${notification.category}]${notification.title} - ${notification.description}`)
              break
          case neo4j.notificationSeverityLevel.UNKNOWN: // or simply 'UNKNOWN'
          default:
              // the raw info came from the server could be found at notification.rawSeverityLevel
              console.log(`[${notification.category}]${notification.title} - ${notification.description}`)
              break
     }
}

More details in the methods documentation and type signature.

@bigmontz
Copy link
Contributor Author

Replaces: #1008

@bigmontz bigmontz force-pushed the 5.x-notificatiosn branch from e9eaa0d to 0010a93 Compare March 16, 2023 10:46
@bigmontz bigmontz marked this pull request as ready for review March 16, 2023 13:53
@bigmontz bigmontz merged commit 6e903e7 into neo4j:5.0 Mar 17, 2023
@bigmontz bigmontz deleted the 5.x-notificatiosn branch March 17, 2023 13:42
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