nswbmw/mongolass là dự án tập trung dữ liệu trên GitHub với 434 sao, viết chủ yếu bằng JavaScript. Elegant MongoDB driver for Node.js.
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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
nswbmw/mongolass thuộc nhóm Data trên TopGit, cùng 4 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về nswbmw/mongolass ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/nswbmw/mongolass là nguồn chính thức.
nswbmw/mongolass có phải mã nguồn mở không?
Có — nswbmw/mongolass phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/nswbmw/mongolass.
nswbmw/mongolass là gì?
nswbmw/mongolass (nswbmw/mongolass) là dự án JavaScript trên GitHub. Theo mô tả gốc: Elegant MongoDB driver for Node.js.
nswbmw/mongolass so với các dự án Data khác thế nào?
nswbmw/mongolass được TopGit xếp vào nhóm Data, với 434 sao GitHub và viết bằng JavaScript. Xem trang chủ đề Data trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Vì sao nswbmw/mongolass được xếp vào nhóm Data?
TopGit xếp nswbmw/mongolass vào nhóm Data dựa trên GitHub topics và mô tả của repo (gắn thẻ: "mongodb", "nodejs", "odm"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về mongolass?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về mongolass.