Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Mike McNeil
@mikermcneil
The change to john resig's lighter-weight i18n package changed some stuff and I believe our docs slipped out of date there (verifying now to be sure). In the mean time, check out https://github.com/sgress454/sails-hook-i18n
Mike McNeil
@mikermcneil
@KSDaemon related to balderdashy/sails#4343
Mike McNeil
@mikermcneil
@KSDaemon ok just double-checked: you'll want to use req.acceptsLanguages()
(i'll add mention of this to the upgrading guide tomorrow morning)
Konstantin Burkalev
@KSDaemon
@mikermcneil Yep! Thanks for your answer, yesterday night i figured that out, but had no power to write about it. I saw also that express.js had this attribute in 3.x versions, but that was removed in 4.x.
brookesb91
@brookesb91
With the lifecycle callbacks on models, is it possible to get the current values for the object?
this.somevalue always returns undefined -
Philip Feldmann
@philipfeldmann
Hello there. Is there a way targeting a policy on the default blueprint api? My goal is to keep the blueprint API in production available for 'admin' only.
Hamza
@hamzaOp
Hello everyone ! , I want to access a controller from the sails object but sails.controllers returns undefined , I'm using 1.0 , it's working on 0.12.
brookesb91
@brookesb91
@hamzaOp are you using actions2 for controllers? If so, they aren’t registered as classic controllers. You could require() them or move the logic into a helper and it’ll be callable from anywhere
Hamza
@hamzaOp
@brookesb91 no I'm using classic actions
Osmel Guarepo
@osmelg
good morning :)
brookesb91
@brookesb91
@hamzaOp Do you definitely need to access the controller? Is there a possibilty to move logic into a helper instead?
Hamza
@hamzaOp
@brookesb91 yes , but I just want to understand the problem , I console log the sails object but it returns 0 controllers , it's like the controllers are not registered.
fabianforce
@fabianforce
Hi who can tell me how to read a local json file in sails v1 ?
brookesb91
@brookesb91
@hamzaOp I believe what you are looking for is controllers.moduleDefinitions
Philip Feldmann
@philipfeldmann
Is there any way to use the new es6 export default syntax for sails entities instead of module.exports? I've tried using babel-node and simply changing the syntax but my controllers will no longer be recognized.
Dean Hantzis
@professor-rage
not sure if this is a issue (not really a bug) in sails v1.0 or sails-postgresql - when using the postgres datastore - if you define a primary key in the model def, but the attribute definition for that pK doesn't include required: true, sails lifts without any error/warning. Only when you try to use that model in code OR when you stop the server do you get an error stating data store identity does not exist.
  ...
  primaryKey: 'id2',
  attributes: {
    id2: {
      type: 'number',
      required: true //if required:true is omited, sails lifts with no warning, but model is not accessible
    },
  }
  ...
    try {
      var a = await SomeModel.find().limit(10);
    } catch(err) {
      console.log(err)
    }
name: 'UsageError',
        code: 'E_INVALID_ARGINS',
        problems: [Array] } },
  isOperational: true,
  adapterMethodName: 'find',
  modelIdentity: 'SomeModel',
  raw: 
   { UsageError: Could not run select() because of 2 problems:
------------------------------------------------------"datastore" is required, but it was not defined.
• "models" is required, but it was not defined.
------------------------------------------------------
smihaljenovic
@smihaljenovic
@mikermcneil Hi Mike. Is it possible in v1.0 to dynamically change db connection and then use models to manipulate data?
newari
@newari
Hello everyone
In v0.12 I am able to create blueprint routes with controller subfolder path name but in v1.0 it's not working. For example, I have controller in v1 sub directory like /api/controller/v1/DemoController.js . For this blueprint autogenerated api path is /api/v1/demo in Sails v0.12 but its not working in v1. In Sails v1 its working on path /api/demo. Is there any solution of my problem?
John Wolfe
@wolfejw86
being very familiar with webpack but relatively unfamiliar with grunt, would anyone be able to tell me if the grunt buildProd task, while using the babel-polyfill works out of the box for async/await for your front end code? (in sails 1.0)
@newari i just did a check and created a test example of this in api/controllers/v1/DemoController.js
John Wolfe
@wolfejw86
i put a test function in there module.exports = { test: (req, res) => res.json({ it: 'works!'})} it worked for GET 'http://localhost:1337/v1/demo/test
did you check and see if in config/blueprints.js you have actions: true ?
newari
@newari
@wolfejw86 thanks for your response. But its not working from my side for default actions like find, update. And value of actions is true in config/blueprints.js
is it also working for find method(default blueprint action ) from your side?
John Wolfe
@wolfejw86
rest is true also??
newari
@newari
yes, its true
John Wolfe
@wolfejw86
does demo have a model as well?
newari
@newari
I have a model with same name of Demo.js
John Wolfe
@wolfejw86
yeah, i can't get it to work that way either
newari
@newari
Its working for custom actions but not blueprint actions (find, update etc)...
John Wolfe
@wolfejw86
yeah same
it works if you take out the v1
is it a common practice to version the models?
(i'm still a relatively new programmer and am unfamiliar with a lot of things)
newari
@newari
yes. But I need the api path with subfolder name.
John Wolfe
@wolfejw86
right
that makes sense if you want to version the models
newari
@newari
Actually I am using the subfolder for grouping my api because I have lots of API in my app. (Not for versioning in my case)
John Wolfe
@wolfejw86
gotcha, so just a lot of models and controllers.
newari
@newari
right
John Wolfe
@wolfejw86
and you want access to the default find/update routes from within those sub directories in the models
newari
@newari
yes.
John Wolfe
@wolfejw86
yeah i'm stumped as well, haven't needed to do that yet with the models. if you don't need to "version" them, but just need to call the default routes for them, they're all accessible though. i guess the other option is to include custom actions in your controllers to keep the url consistent (having v1,v2,etc. in it versus just api/demo1, api/demo2)
newari
@newari
But I have 50+ Model with 200+ Blueprint APIs. And the APIs are also used by many apps. Its difficult for me to change the path of APIs. It was working fine with V0.12