Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ES6 6.0 / Node v4.2.4+ Peer Review for v6.0.0 #73

Open
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

edwardhotchkiss
Copy link
Owner

  • mostly ready, needs to return a promise always
  • checking for ES5 legacy code
  • MORE tests
  • 2 space indents on everything
  • Documentation - up to date?

If you guys have a few mins! @Jokero @niftylettuce @tsm91 @MatthewRayfield @connected-dalmer @villesau @shime - also please make sure that you are in contributors in package.json, thanks!

@@ -1,8 +1,7 @@
language: node_js

node_js:
- "4"
- "stable"
- "4.2.4"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to run tests only on nodejs 4.2.4?

@edwardhotchkiss
Copy link
Owner Author

@Jokero - made the changes, need to figure out why tests are failing with some debugging later today. Thanks for the review!

result.pages = Math.ceil(data.count / limit) || 1;
}
if (typeof callback === 'function') {
return callback(null, result);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not return result of callback as promise value:

if (typeof callback === 'function') {
  callback(null, result);
}
return Promise.resolve(result);

@edwardhotchkiss
Copy link
Owner Author

@Jokero Check it out, all tests passing. Looks pretty sexy. We can make some code smaller but it seems to be working great now. Thoughts on release as v6.0.0?

@@ -18,13 +20,13 @@

function paginate(query, options, callback) {
query = query || {};
options = Object.assign({}, paginate.options, options);
let select = options.select;
options = options || {};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove paginate.options?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jokero There was nothing ever sent into paginate.options and that which was wasn't being tested. It could be added if we had it in the docs and tests for it ... feel free to push :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edwardhotchkiss
Copy link
Owner Author

@Jokero I added back paginate.options, the id field is back. One issue left is the limit : 0. The test was passing because of how the query was built. I think that no one will ever use limit as zero. Thoughts? Otherwise I think that we're good to go. 🎱

@edwardhotchkiss
Copy link
Owner Author

Also all tests passing except with limit zero.

@Jokero
Copy link
Collaborator

Jokero commented Jan 10, 2016

I use limit: 0 because it's useful in rest api to get only metadata (page, total, but not documents). Maybe anyone else uses this functionality

@edwardhotchkiss
Copy link
Owner Author

Yeah limit:0 in MongoDB defaults to all docs as the default behavior. I'll make sure that there is a note of it in the docs.

@Jokero
Copy link
Collaborator

Jokero commented Jan 11, 2016

Pagination is fetching and counting. If we set limit: 0 we disable fetching. It's very cool

@edwardhotchkiss
Copy link
Owner Author

@Jokero limit:0 back to original ... 🎱

edwardhotchkiss and others added 2 commits January 11, 2016 13:50
Instead of create an object and then filter by avalable options from
object keys, we can use an array and resolve a promise for limit: 0
option
@antony
Copy link

antony commented Jun 27, 2016

Is this due to be merged sometime soon?

Reason being is that I want to start adding a feature but I don't want to do it on the old codebase and end up in merge hell :)

@simison simison mentioned this pull request Aug 31, 2016
@simison
Copy link

simison commented Aug 31, 2016

@antony see #93 — wanna continue bringing this PR forward?

@antony
Copy link

antony commented Aug 31, 2016

Ah that's terrible news. Sorry to hear it.

@simison I can have a look at getting this PR finalised, I'm quite time constrained so I don't know how soon I'll be able to do it, but I'll update this ticket as I progress.

Simple way to handle/create required promises internally
@fiznool fiznool mentioned this pull request Sep 29, 2016
*/

mongoose.Promise = global.Promise;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be wary about this line. Some people like to set mongoose.Promise to their own promise implementation (e.g. bluebird). Overwriting it here would cause them lots of headaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants