You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And dont forget how much the codebase would benefit from arrow functions (also the docs).
Maybe this would also be the time to refactor the code so that "instances" are actually instances of models? E.g. Sequelize.prototype.define would return an anonymous class that extends the Model class, and "instances" will actually be instances of that class.
And optionally, you can pass define you own class as the first argument as long as it extends Model, so you can actually define getters/setters as real getters/setters and customize your model with everything, even toJson().
@felixfbecker yeah, there's another issue for ES6 class support, you can add your help and opinons here.
For ES6 we're probably looking at something like:
@mickhansen No, please please please. Don't do this. Thats what I hate the most about PHP ORMs, that just because the language is so inflexible you always have to implement these methods that do nothing but return the configuration. But Javascript is flexible. You can assign stuff on classes. You can build classes dynamically. Think about it, currently define is basically a class factory. You pass it arguments beforehand that define how this new model will map to the database.
With a class based approach, this would map perfectly to decorators - which are nothing but a function that take a class (or anything) and decorate it with additional info - at declaration time. Until decorators are here, this would mean that you simply pass define the class as a first argument, and the additional info as second argument.
I think static methods should have nothing to do with that additional info. You could add your own static methods like findByMyCustomAttribute(), just like you could add your own instance methods and getters and setters. It also doesnt make sense - the table name is never dynamic. It should be defined once and not returned by a method. Btw, your example doesnt work in ES6, as there are no arrow methods on classes. You would have to write a full method with a return statement.
@felixfbecker the ES6 class system does now allow static properties defined in the class method.
Decorators are not here for everyone yet, and we'd love to support ES6 classes fully still.
What would you suggest, with a code example, instead of going full ES6 classes?
I suggested this syntax because that's how React does it and i find that to be okay, but i certainly welcome any suggestions :)
The implementations however needs to be mappable from sequelize.define()
To return to original subject of this issue, how about continuing to test against node v0.12 in Travis but (1) making sure those test runs are scheduled after the v4 and v5 test runs, and (2) marking them as allowed to fail in Travis?
That way you'd get the green tick from Travis quicker, but still be able to keep an eye on whether anything is broken on node v0.12.
@verdier Well @mickhansen was saying he'd like v0.12 to remain unofficially supported but to stop testing against it to speed up Travis. I have no idea how support for both v0.12 and ES6 is going to be achieved - I'm just saying that if the aim is to maintain some support for v0.12, we need some indication of when things have got broken.
There is no support for ES6 in node 0.12 and even with --harmony it's still very incomplete. One class or => somewhere in the code and none of the v0.12 tests will pass...
We will be doing ES6 through babel, we'll be compiling to code that should still run on Node v0.10.
We just don't want to bother with running CI for it. Having 0.12 as an allowed failure could be a way to go.
I think I mentioned in another issue thread I've been wondering if there's a way to speed up the test runs by running multiple tests in parallel (within the same Travis process). This would speed things up a lot as most of the time is spent waiting for async IO with the database. But I don't know if anyone's already built something like this for mocha.
@overlookmotel Tricky for our integration tests which all hit the database though, would have to have isolated databases, but i suppose that could actually be doable on Travis.
Activity
alitaheri commentedon Jan 13, 2016
I agree with this 👍
verdier commentedon Jan 13, 2016
Agree 👍 and project could use ES6 features such as
classor evenco...?! 🔋mickhansen commentedon Jan 13, 2016
@verdier We're likely not moving to generators internally, since ideally we'd still have unofficial support for older v8 versions with less features.
We plan to add class support yes, however we still need to support the old sequelize.define :)
felixfbecker commentedon Jan 13, 2016
And dont forget how much the codebase would benefit from arrow functions (also the docs).
Maybe this would also be the time to refactor the code so that "instances" are actually instances of models? E.g.
Sequelize.prototype.definewould return an anonymous class that extends the Model class, and "instances" will actually be instances of that class.felixfbecker commentedon Jan 13, 2016
And optionally, you can pass
defineyou own class as the first argument as long as it extendsModel, so you can actually define getters/setters as real getters/setters and customize your model with everything, eventoJson().mickhansen commentedon Jan 13, 2016
@felixfbecker yeah the plan is to change it so instances are instanceas of models, we need to change a lot of model checks though.
Plan is to support both ES6 classes and define.
As for arrow functions, definitely :) Away with var self = this
felixfbecker commentedon Jan 13, 2016
Then in the very distant ES7 future instead of
defineyou could use decorators on your model classmickhansen commentedon Jan 13, 2016
@felixfbecker yeah, there's another issue for ES6 class support, you can add your help and opinons here.
For ES6 we're probably looking at something like:
felixfbecker commentedon Jan 13, 2016
@mickhansen No, please please please. Don't do this. Thats what I hate the most about PHP ORMs, that just because the language is so inflexible you always have to implement these methods that do nothing but return the configuration. But Javascript is flexible. You can assign stuff on classes. You can build classes dynamically. Think about it, currently
defineis basically a class factory. You pass it arguments beforehand that define how this new model will map to the database.With a class based approach, this would map perfectly to decorators - which are nothing but a function that take a class (or anything) and decorate it with additional info - at declaration time. Until decorators are here, this would mean that you simply pass define the class as a first argument, and the additional info as second argument.
I think static methods should have nothing to do with that additional info. You could add your own static methods like
findByMyCustomAttribute(), just like you could add your own instance methods and getters and setters. It also doesnt make sense - the table name is never dynamic. It should be defined once and not returned by a method. Btw, your example doesnt work in ES6, as there are no arrow methods on classes. You would have to write a full method with a return statement.Just my 0.02€
mickhansen commentedon Jan 14, 2016
@felixfbecker the ES6 class system does now allow static properties defined in the class method.
Decorators are not here for everyone yet, and we'd love to support ES6 classes fully still.
What would you suggest, with a code example, instead of going full ES6 classes?
I suggested this syntax because that's how React does it and i find that to be okay, but i certainly welcome any suggestions :)
The implementations however needs to be mappable from sequelize.define()
verdier commentedon Jan 14, 2016
@mickhansen @laggingreflex
Just to let you know, here is what we use today: (ES7 + Decorators + Babel)
But that's not a solution for ES6 without transpiler... For ES6 we could have something like that:
and, bonus, to use
co(we have build a minimalistic libco-wrap-proto):mickhansen commentedon Jan 14, 2016
Thanks for the suggestions @verdier, although the ModelFactory stuff seems non-idiomatic
mickhansen commentedon Jan 14, 2016
ES7+ Property Initializers would solve this even better than decorators
14 remaining items
overlookmotel commentedon Jan 15, 2016
To return to original subject of this issue, how about continuing to test against node v0.12 in Travis but (1) making sure those test runs are scheduled after the v4 and v5 test runs, and (2) marking them as allowed to fail in Travis?
That way you'd get the green tick from Travis quicker, but still be able to keep an eye on whether anything is broken on node v0.12.
verdier commentedon Jan 15, 2016
What about ES6 features?
overlookmotel commentedon Jan 15, 2016
@verdier Well @mickhansen was saying he'd like v0.12 to remain unofficially supported but to stop testing against it to speed up Travis. I have no idea how support for both v0.12 and ES6 is going to be achieved - I'm just saying that if the aim is to maintain some support for v0.12, we need some indication of when things have got broken.
verdier commentedon Jan 15, 2016
There is no support for ES6 in node 0.12 and even with
--harmonyit's still very incomplete. Oneclassor=>somewhere in the code and none of the v0.12 tests will pass...mickhansen commentedon Jan 15, 2016
We will be doing ES6 through babel, we'll be compiling to code that should still run on Node v0.10.
We just don't want to bother with running CI for it. Having 0.12 as an allowed failure could be a way to go.
felixfbecker commentedon Jan 15, 2016
Should this also mean to drop the bluebird dependency?
mickhansen commentedon Jan 15, 2016
No, ES6 promises are slower and lack features we rely on, and do not necessarily exist in older versions.
sushantdhiman commentedon Jan 15, 2016
Yes please remove other Node and IO versions from CI, +1
overlookmotel commentedon Jan 16, 2016
I think I mentioned in another issue thread I've been wondering if there's a way to speed up the test runs by running multiple tests in parallel (within the same Travis process). This would speed things up a lot as most of the time is spent waiting for async IO with the database. But I don't know if anyone's already built something like this for mocha.
mickhansen commentedon Jan 16, 2016
@overlookmotel Tricky for our integration tests which all hit the database though, would have to have isolated databases, but i suppose that could actually be doable on Travis.
sushantdhiman commentedon May 24, 2016
Can it be closed now as #5918 has been merged to master ? @janmeier @mickhansen
overlookmotel commentedon May 24, 2016
Where shall we discuss what ES6 features should be permitted in Sequelize v4 codebase? Or is it basically anything that's supported in node v4?
mickhansen commentedon May 24, 2016
#5898
mickhansen commentedon May 24, 2016
@overlookmotel i guess basically anything that's supported by v4, but we haven't decided yet.