Mongorito v3 #138
Comments
Nice roadmap, do you plan to push the branch v2 anytime soon? |
Awesome! Mongorito fits perfect in Adonisjs syntax also! Thank for your nice working! |
It's a WIP, will push the branch asap. |
@mathieug v3 branch pushed up - https://github.com/vdemedes/mongorito/tree/v3. |
Big update! Everything except the following is done:
|
Update! Mongorito v3 is ready and now only needs a new readme. |
Could I operate with mongorito' predefined fields like
camel cased fields in v3? |
Great job! 😸 When do you plan release v3? Do you release alpha/beta of v3? |
@nervgh I want to make those field names configurable, I feel like both of those are good defaults.
I'd rather not give any ETAs. I still want to implement saving of models inside models (that's what MongoDB basically is, nested documents :D) And don't forget the most annoying part - documentation.
For now, you can use |
@vdemedes
Exactly! I will install mongorito from branch
I think my project recursive-iterator may be helpful for your purposes. Using it you could iterate through nested structures very simple. |
@vdemedes It looks like I cannot install
|
@nervgh package.json allows it, why would you think it wasn't? What error are you getting? |
OH, I'm not committing |
I think I should get rid of unsupported ES6 syntax and remove babel transpilation of the source. |
@nervgh Removed babel, now the install should go fine! |
@vdemedes thanks! I need let queryBuilder = new MyModel.Query(); // Query has been exported as the static property of Model
queryBuilder.in(key, array);
queryBuilder.sort(key, direction);
// etc
let result = yield queryBuilder.exec(); |
@nervgh Sorry for late response, here's how you can use const posts = await Post.where('title').in(['Bad title', 'Great title']).find(); |
Great ORM and I'm excited to see continued work on this project. |
@niallobrien Thank you, means a lot to me! I updated the docs, so v3 release is going to be (hopefully) released soon. |
Can I suggest a migration feature? |
@vinhtq Could you elaborate what you mean exactly? |
I'd love to see an adapter for Feathers.js |
@vdemedes Something looks like this: https://github.com/derickbailey/migroose |
What about static configure method for each model? It's useful when creating indexes or adding global hooks. |
Since ensureIndex is declared, should mongorito V3 add a new createIndexes method too? http://stackoverflow.com/questions/25968592/difference-between-createindex-and-ensureindex-in-java-using-mongodb |
@vinhtq It's out of scope of this library, it's just a database abstraction.
@zaaack Might be a good idea (v2 had it), will see what can be done here. Thanks!
@zaaack From what I've read on SO link you referenced, |
@vadimdemedes Actually insert, remove, update are all declared too by something like insertOne and insertMany... http://mongodb.github.io/node-mongodb-native/2.2/api/Collection.html#insert |
The static configure method, I find out an implementation by v3's plugin system(I love that! ). Maybe can have some built-in plugins. db.use(function staticConfigure(model) {
model.connection().then(conn => {
// static configure
model.configure && model.configure()
})
}) |
Allow sort with array arguments, hash option can't guarantee the order of multi-fields, new driver and mquery support array sort arguments. https://github.com/aheckmann/mquery/blob/master/lib/mquery.js#L1214 PR: #167 |
Any plans to move to async/await? |
@niallobrien Mongorito v3 (and legacy v2) already returns promises for all methods where async operations happen. You can use async/await on any of them. |
Since v3 is out, closing this issue. |
Hey everyone, Mongorito's been quiet for a long time now, but it deserves more attention that it has right now. I've been looking into library's code, repository issues and pull requests and decided to roll out a v2 of Mongorito in the coming weeks.
Current state of Mongorito's codebase is not what I want it to be. It is bloated and it does not fit a variety of use cases. Here's a plan of improvements to build into a new major release. Note, that it will not be compatible with the current version, so a migration guide will be provided.
Roadmap
1. No more singleton Mongorito instance
Instead of this:
We're going to have something like this:
Singleton
Mongorito
object leads to a dirty code in Mongorito's codebase and makes the whole library less flexible. It makes connecting to multiple databases inconvenient.2. Drop .extend() and go ES6 only
After the next release,
.extend()
is no longer to be included in the core. To define a model, you will have to use ES6 classes.3. Registration of models
Since singletons are to be discontinued (see point nr. 1) and the only way to define a model is through an ES6 class (see previous point), there has to be a way to connect models to databases. In Mongoose you have
db.model()
method and we'll have something similar:I think this is simple enough and easy to understand what it's for.
4. Export only necessary properties from the native driver
Currently, Mongorito exports every property with a few exceptions from the native driver. I don't think it serves any purpose, as what's most often needed is just
ObjectId
.5. Drop generator support in hooks
Since you can define hooks explicitly for
before
,after
andaround
events, there's no need for flow control via generator functions. Next release will only support "regular" functions and functions that returnPromise
s (async functions).Note, you will still be able to use code like this:
This change is related only to defining hooks inside models.
6. Use query building library like mquery
I think it would be wise to not reinvent the wheel and wrap some query building library (like mquery) to handle the queries in Mongorito. Those libraries usually have good command coverage, so I think most people's needs would be satisfied.
Feel free to discuss and add anything to this list.
The text was updated successfully, but these errors were encountered: