For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Open sourceSupportFAQsDocs Home
DocumentationAPI referenceRelease notes
DocumentationAPI referenceRelease notes
  • Release notes
    • Overview
    • Changelog
      • Overview
      • AngularJS not supported in manual tasks
      • Audit Trail collection removed
      • Broken references
      • Data Path property renamed
      • Default adapter protocol
      • DryRun and View DryRun manual tasks removed
      • Help and Status API endpoints removed
      • Integration API routes removed
      • Itential Platform key removed from global config
      • Itential Tools updated
      • IWAN tasks removed
      • Job variable changes in child workflows
      • Merge task variables — null vs. undefined
      • Message queue libraries removed
      • Database no longer supports callbacks
      • NSO features removed
      • Operations Manager API changes
      • Inline images removed from pre-built README files
      • Reserved method output name
      • Service Manager UI removed
      • Task error config option in AG Manager
      • Seed scripts removed in Template Builder
      • Transformations using thisArg feature
      • Workflow Engine API routes removed
LogoLogo
Open sourceSupportFAQsDocs Home
On this page
  • Breaking change notice
  • Global database change
  • What should I do?
  • Option 1: Use then() and catch()
  • Option 2: Use async/await
Release notesBreaking changes

Database no longer supports callbacks

Was this page helpful?
Previous

NSO features removed

Next
Built with

Breaking change notice

Itential Platform 2023.2 introduces a breaking change in which the MongoDB Node Driver version no longer supports callbacks.

Global database change

Itential has upgraded the MongoDB Node Driver version used in the global database variable available to custom applications and adapters. The new version no longer supports callbacks — it uses a Promise-only API. All other arguments (filters, updates, options, etc.) remain unchanged. Previously, the last argument of all database operations accepted a callback function that was invoked when the operation completed.

What should I do?

The following example shows a callback-based operation using the global database variable. Callback functions used an “error-first” syntax, where any error was returned as the first argument and the result of a successful operation as the second:

1class myCog {
2 myMethod(name, callback) {
3 const filter = { name };
4
5 database.collection('my-collection').findOne(filter, (err, doc) => {
6 if (err) {
7 return callback(null, err);
8 }
9 return callback(doc);
10 });
11 }
12}

There are two approaches for migrating to the Promise-based API:

Option 1: Use then() and catch()

Chain .then() and .catch() methods on the returned Promise. Each takes a function executed on success or failure:

1class myCog {
2 myMethod(name, callback) {
3 const filter = { name };
4
5 database.collection('my-collection').findOne(filter)
6 .then((doc) => {
7 return callback(doc);
8 })
9 .catch((err) => {
10 return callback(null, err);
11 });
12 }
13}

Option 2: Use async/await

Define the method as async and await the Promise. This produces a flatter, simpler syntax. If a Promise is awaited, it returns the successful result or throws an error if the Promise rejects:

1class myCog {
2 async myMethod(name, callback) {
3 const filter = { name };
4
5 try {
6 const doc = await database.collection('my-collection').findOne(filter);
7 return callback(doc);
8 } catch (err) {
9 return callback(null, err);
10 }
11 }
12}

If you experience any issues or need assistance with your migration, contact the Product Support Team.