M
M
microf2015-12-29 15:10:17
JavaScript
microf, 2015-12-29 15:10:17

How to work with sails.js?

With coming!
1) How to use translation on the server side in conjunction with angular? I want the angular service to pick up the content already translated by the server. In sails.js, i18n-node is included in the box and it provides a getLocale() method with which you can get the current locale.
You can make a model like

module.exports = {
  attributes: {
      name : String,
      title : { 
                  en : {type: 'string'},
                  ru : {type: 'string'},
                  de : {type: 'string'},
                       }
      }

and something like this in the controller?
var
      loc = req.getLocale();
        Main.findOne({name:'header'}).exec(function findOneCB(err, found){
  А здесь как то отфильтровать значения с помощью getLocale() ???? Или как запрос написать?
});

Or don’t tell me schemes (and selection) at all for mongo for storing dynamic content (not menus, but articles or a list of options for selects) and for menu elements (well, that is, I use i18n-node, I make files with locales or store them in base and give angular only the already translated element (I know about angular-translate, but why load the client extra if it is possible on the server)
2) What to use for user roles? I installed passport.js, but somehow it's not clear how to work with roles there. Can you give me an example or module?
3) Policies - what are they for? Well, that is, that they should be used to check access - this is understandable. Is it possible to shove some more logic there? For example, checking for used user bonuses, or something else
4) Services - do I need to use them to work with the database? Do I understand correctly that these are some kind of singletons, which will then be available everywhere? Those. by analogy with angular, can you not use controllers at all?
5) I would like to have an admin panel, which will be made standard sails.js (without angular) and for the client already via api only the client on angular. How in this case it is correct to allocate an admin panel? (in routes you will have to give a "link" to the view, but in the case of angular this is not necessary)
I hope I asked the questions clearly ((

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question