> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.itential.com/itential-platform/2023-2/release-notes/breaking-changes/mongo-database-no-longer-supports-callbacks/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.itential.com/_mcp/server. # Database no longer supports callbacks > Breaking change notice that the MongoDB Node Driver used in the global database variable no longer supports callbacks in 2023.2, requiring migration to Promises or async/await. ## 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: ```js class myCog { myMethod(name, callback) { const filter = { name }; database.collection('my-collection').findOne(filter, (err, doc) => { if (err) { return callback(null, err); } return callback(doc); }); } } ``` 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: ```js class myCog { myMethod(name, callback) { const filter = { name }; database.collection('my-collection').findOne(filter) .then((doc) => { return callback(doc); }) .catch((err) => { return callback(null, err); }); } } ``` ### 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: ```js class myCog { async myMethod(name, callback) { const filter = { name }; try { const doc = await database.collection('my-collection').findOne(filter); return callback(doc); } catch (err) { return callback(null, err); } } } ``` If you experience any issues or need assistance with your migration, contact the [Product Support Team](https://itential.atlassian.net/servicedesk/customer/portals). > Breaking change notice that the MongoDB Node Driver used in the global database variable no longer supports callbacks in 2023.2, requiring migration to Promises or async/await.