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

Plugin is not working with sails v1.x #5

Open
OPADA-Eng opened this issue Jul 3, 2018 · 8 comments
Open

Plugin is not working with sails v1.x #5

OPADA-Eng opened this issue Jul 3, 2018 · 8 comments

Comments

@OPADA-Eng
Copy link

The plugin is not working any more with the current version of sails js 1.0
can you please post an upgrade soon ?

@kristian-ackar
Copy link
Owner

I would appreciate if you create a pull request with patch :-)

@pixnlove
Copy link

pixnlove commented Mar 24, 2019

FYI, in SailsJS v1.0, sails-hook-blueprint-count is natively integrated.
https://sailsjs.com/documentation/reference/waterline-orm/models/count

@dehimer
Copy link

dehimer commented May 14, 2019

FYI, in SailsJS v1.0, sails-hook-blueprint-count is natively integrated.
https://sailsjs.com/documentation/reference/waterline-orm/models/count

For controllers? For models it is was available before.

@pixnlove
Copy link

@dehimer yes you can call it with await Model.count(criteria) in your controller now.

@dehimer
Copy link

dehimer commented May 14, 2019

@dehimer yes you can call it with await Model.count(criteria) in your controller now.

I implemented count now. Added count action to base/Controller and added routes to config/routes.
If you will not specify route - you will get undefined model in options and get error in
const Model = actionUtil.parseModel(request);

@dehimer
Copy link

dehimer commented May 14, 2019

module.exports = {
  /*
   * Generic count action for controller.
   *
   * @param   {Request}   request
   * @param   {Response}  response
   */
  count(request, response) {
    console.log('count');
    const Model = actionUtil.parseModel(request);
    const criteria = actionUtil.parseCriteria(request);

    Model
      .count(criteria)
      .exec((error, count) => {
        if (error) {
          console.log(error);
          response.negotiate(error);
        } else {
          console.log(count);
          response.ok({ count });
        }
      });
  },
};

@Lorex
Copy link

Lorex commented May 20, 2019

@dehimer How do I specify my routes?

I tried the following code but get "No model specified in route options." error 😢

'GET /*/count' : { action: 'main/count' }

@dehimer
Copy link

dehimer commented May 21, 2019

@dehimer How do I specify my routes?

I tried the following code but get "No model specified in route options." error 😢

'GET /*/count' : { action: 'main/count' }

I did it in this way:

'GET /timeentry/count': {
    controller: 'TimeEntryController',
    action: 'count',
    model: 'timeentry'
  },

For every model.
Looks ugly, but works.

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

No branches or pull requests

5 participants