Promise-based library for implementing transactions in MongoDB using a two-phase commit approach. Version 2.1.5 is the latest stable release. It provides a task-based API for defining a series of CRUD operations that either all succeed or are rolled back entirely. Unlike MongoDB's native transactions (which require replica sets), Fawn works with standalone MongoDB instances. It supports both native MongoDB driver and Mongoose, and includes GridFS file support. The library has not seen updates since 2019 and the repository is archived.
npm install fawnNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Sets up Fawn with Mongoose connection, creates a task with two updates, and runs it with rollback on failure.
Call Fawn.init(connection) at the start of your application.
Use native MongoDB transactions (require replica sets) or keep using Fawn with standalone MongoDB.
Do not manually modify or delete the 'fawn_sequences' collection.
Use const Fawn = require('fawn'); instead of import.Add const Fawn = require('fawn'); at the top of your file.Ensure you are using require('fawn') and version >=2.0.0.Call Fawn.init(connection) before Fawn.Task(). Then const task = Fawn.Task();