nswbmw/mongolass is a Data project on GitHub, written primarily in JavaScript. It has 432 stars. Elegant MongoDB driver for Node.js.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
I've been using Mongoose for years, it's great but complex sucks, so i wrote Mongolass. Mongolass is not simply mimicking Mongoose, but rather draw on the advantages of mongoose redesigned the architecture. Mongolass has some exciting features different from Mongoose:
Pure Schema. In Mongoose, Schema and Model and Entity are confused.
Schemas not only define the structure of your document and casting of properties, they also define document instance methods, static Model methods, compound indexes and document lifecycle hooks called middleware.
In Mongolass, Schema is only used for defining the structure of your document and casting of properties, Model used for retrievaling data from mongodb and register plugins, Entity(as result) is plain object. Schema is also optional.
Awesome plugin system. Mongoose plugin system is not strong enough, eg: .pre, .post, use async next(). In Mongolass, we can register a plugin for Model or global mongolass instance. like:
User.plugin('xx', {
beforeFind: function (...args) {},// or function return Promise
afterFind: async function (result, ...args) {
console.log(result, args)
...
},
// afterFind: async function (result, ...args) {
// console.log(result, args)
// ...
// }
})
Above added two hook functions for User, when User.find().xx().exec() is called, the execution order is as follows:
beforeFind(handle query args) -> retrieve data from mongodb -> afterFind(handle query result)
Mongolass's plugins could be substituted for Mongoose's (document instance methods + static Model methods + plugins).
Detailed error informations. see usage.
User
.insertOne({ name: 'nswbmw', age: 'wrong age' })
.exec()
.then(console.log)
.catch(console.error)
/*
{ TypeError: ($.age: "wrong age") ✖ (type: number)
at Model.insertOne (/Users/nswbmw/Desktop/test/node_modules/mongolass/lib/query.js:105:16)
at Object.<anonymous> (/Users/nswbmw/Desktop/test/app.js:23:4)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:598:3
validator: 'type',
actual: 'wrong age',
expected: { type: 'number' },
path: '$.age',
schema: 'UserSchema',
model: 'User',
op: 'insertOne',
args: [ { name: 'nswbmw', age: 'wrong age' } ],
pluginName: 'MongolassSchema',
pluginOp: 'beforeInsertOne',
pluginArgs: [] }
*/
According to the error instance, esay to know age expect a number but got a string, from error stack know it's broken on app.js:23:4 and the operator is Model.insertOne.
Schema
see another-json-schema, support default and required.
What's difference between number and Mongolass.Types.Number ?number only check type, Mongolass.Types.Number will try to convert value to a number, if failed then throw error.
Plugins
mongolass.plugin(pluginName, hooks)// register global plugin
User.plugin(pluginName, hooks)// register model plugin
How does nswbmw/mongolass compare to other Data projects?
nswbmw/mongolass is tracked by TopGit in the Data category, with 432 GitHub stars and written in JavaScript. Browse the Data topic page on TopGit to compare it against similar projects by stars and activity.
Is nswbmw/mongolass open source?
Yes — nswbmw/mongolass ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/nswbmw/mongolass.
What else is in the Data space?
nswbmw/mongolass is tracked by TopGit under the Data category, alongside 4 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What is nswbmw/mongolass?
nswbmw/mongolass (nswbmw/mongolass) is a JavaScript project on GitHub. From the project's own README: Elegant MongoDB driver for Node.js.
Where do I read more about nswbmw/mongolass?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/nswbmw/mongolass is the definitive source.
Why is nswbmw/mongolass categorized under Data?
TopGit places nswbmw/mongolass in the Data category based on its GitHub topics and description (tagged: "mongodb", "nodejs", "odm"). Categories are assigned from real repository metadata, not editorial guesswork.
Read full README in the tab above.
Want a second opinion on mongolass?
Ask an AI that can read this page — one click and you get its take on mongolass.