From Mongoose
This guide showcases the main differences between Mongoose and Blini, and how to adapt your code to switch to Blini.
Promises-only, no more callback
While Mongoose supports both callback and promises. Blini does not support callback, but only promises.
Documents are immutable
Documents in Mongoose were mutable, you can work with the same document instance:
While in Blini, Documents should be treated as values rather than objects:
Queries are not promises
Mongoose has a very special API for Query that can be used as promises using .then
.
Blini requires an explicit call to .exec()
to execute the query and gain access to the promise.
No hooks
Blini does not provide an hooks API. Extending the library behavior can be done while inheriting a model.
For example to hook the save, in mongoose you can use .pre
and .post
.
But the .post
cannot be executed in the async chain, which can cause issues since documents are mutable.
In Bline, while this example should be adapted using a proper validations, you can compose .save
:
Last updated