by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 11:18
    sailsbot unlabeled #4590
  • 11:18
    Bhavykapadiya commented #4590
  • 08:00
    sailsbot unlabeled #7018
  • 08:00
    NachtRitter commented #7018
  • Jul 07 23:53
    mikermcneil commented #7018
  • Jul 07 17:12
    johnabrams7 labeled #6998
  • Jul 07 17:09
    johnabrams7 labeled #6999
  • Jul 07 17:09
    johnabrams7 labeled #6999
  • Jul 07 17:06
    johnabrams7 labeled #7006
  • Jul 07 17:04
    johnabrams7 labeled #7005
  • Jul 07 17:04
    johnabrams7 unlabeled #7005
  • Jul 07 17:04
    johnabrams7 labeled #7005
  • Jul 07 17:04
    johnabrams7 labeled #7005
  • Jul 07 17:04
    johnabrams7 labeled #7005
  • Jul 07 17:03
    johnabrams7 labeled #7008
  • Jul 07 17:03
    johnabrams7 labeled #7008
  • Jul 07 17:03
    johnabrams7 labeled #7008
  • Jul 07 17:03
    johnabrams7 labeled #7010
  • Jul 07 17:01
    johnabrams7 labeled #7011
Agustín Siles
@agustinsiles
Something like this:
Product.create(req.allParams(), function(err, product) {
if (err) return res.json(err.status, {err: err});
res.json(product);
});
There I'm sending the exact object I created instead
César
@ICesarI
@agustinsiles, just use find instead of returning the new product.
Agustín Siles
@agustinsiles
@ICesarI you mean something like this?
Product.create(req.allParams(), function(err, product) {
if (err) return res.json(err.status, {err: err});
Product.find({user: user_id}).exec(function findCB(err, products){
if (err) return res.json(err.status, {err: err});
res.json(products);
});
});
Agustín Siles
@agustinsiles
I thought of that but I thought there would be a prettier way to do it
thanks!
César
@ICesarI
@agustinsiles, if you want all of them with curly brackets is enough Product.find({}).exec(..
Agustín Siles
@agustinsiles
yeah I know, I copied and pasted the wrong code, ha
Chris Kee
@ckee83
Hi all, I'm observing floating point precision loss when creating a record with 'float' attribute to my postgres db.
-133.234817 -> -133.235
Mike McNeil
@mikermcneil
@ckee83 What kind of column is it?
@japel re that exit code: that is indeed strange
@everyone finally got an auto-deploying version of sailsjs.org that rerenders documentation when changes are pushed to master on sails-docs: https://new-sailsjs-website-preview.herokuapp.com/documentation/reference/waterline-orm/models/find
That page I just linked to is an example of the cleaned up format that were working on converting the rest of the reference docs to match-- if you have any feedback open an issue in sails-docs and lemme know. Thanks!
khalilifar
@khalilifar
Hey, Anybody knows where sessions are stored in sails (not using redis or any other session store)
My problem is i am storing some user details in session to speed things up and not having to make a database call everytime i need info like user permissions etc.
When these info change by user himself well i can update the session. but when an admin updates those info. user won't be updated until they logout and login again( so session is destroyed and created again by updated data from database)
how can i access another user's session ? any body else having the same problem ?
Richard van Zon
@rvanzon
@khalilifar I think you better cache your data manually by using Redis/Memcached directly or create a model using the Redis-adapter. That way accessing the data system-wide is also easier.
so for example, you set the value of key “datakey” + data_id with the data. Every call you check if there is a cached version of the data. If so, return it immediately (using a policy for example). If the admin changes something you update the value of that key.
you can also add this logic to your model, as a static function for example.
khalilifar
@khalilifar
TY, yes i knew i could do this by Redis/Memcached the problem is i have to install this in a few places both windows and linux was wondering if it was possible without complicating setup. but i guess i have no choice. Thanks for the quick reply rvanzon
Ivan Feofanov
@Ivan-Feofanov
Hi. Anybody know what i shoul do with error "TypeError: req.params is not a function". I try to send data from form to controller, but get this error
Jan Viktor Apel
@japel
@mikermcneil It was skipper-gridfs... The currently published version is not node 4 compatible... I guess it has something to do with the mongodb dependency being a bit old... when I use master everything works as expected
Eden Corbin
@edencorbin
Anybody use cluster with sails to get multi-core performance? Never have, wondering what benefits might result. I think most lag in my applications are generally db lookups to mongo.
Kevin Turner
@kpturner

Anybody use cluster with sails to get multi-core performance? Never have, wondering what benefits might result. I think most lag in my applications are generally db lookups to mongo.

I haven't (yet) but I intend to.....but unsure if I should go with pm2 instead to be honest.

Mike McNeil
@mikermcneil
@japel ah gotcha- I'll add something to the readme
@edencorbin re: optimization: spent a bunch of time on this early last year (for us it was postgresql). Definitely suggest picking one particular endpoint that is slow, then drilling down into it further from there.
@edencorbin for us, it was cases where we were doing O(N) queries in some crazy async.whilst() code
Eden Corbin
@edencorbin
@mikermcneil thanks that's helpful, i'll dig into that.
Mike McNeil
@mikermcneil
@edencorbin good luck :)
Agustín Siles
@agustinsiles
Hi @mikermcneil , which module would you recommend to upload files?
Raimo Pitkänen
@rapitkan
Hello. Has anyone managed to upload a file using DropZone?
Mike McNeil
@mikermcneil
@agustinsiles if you can get away with doing client-side uploads, it's always a good idea. But realistically that isn't always an option. So when you need streaming uploads that are handled on your backend, you should use Skipper (which is built in to Sails). That's what we use.
Raimo Pitkänen
@rapitkan
Thanks. I have read about Skipper and I’m willing to try using it but the problem is seems to be how to specify a route for file upload.
I have tried to add a route like this
  'post /upload/file/': 'FilesService.uploadFile'
But I get 404
I have many other routes specified in routes.js but they are getroutes… Now I’m wondering if you can’t specify routes for postrequest at all… I’m confused.
NizarBlond
@NizarBlond
folks, how do I read the list of collections from MongoDB using Waterline? I want to avoid using listCollections of Mongoose
Mike McNeil
@mikermcneil
@NizarBlond you can use .native() to send a query directly to mongodb. For anything it doesn't support, I'd recommend using the mongo driver directly
NizarBlond
@NizarBlond
native() should support listCollections?
Mike McNeil
@mikermcneil
@NizarBlond definitely not saying that- I couldn't tell you off the top of my head. .native is just a convenience feature
NizarBlond
@NizarBlond
the thing is that native is used by models MyModel.native(function()..)
no?
I want to get list of collections available in the database
Mike McNeil
@mikermcneil
@rapitkan standard troubleshooting process for stuff like this is (1) make sure you've restarted the server (2) make sure you're sending a post request to the right endpoint (3) make sure everything is spelled correctly (4) make sure the route isn't being overridden by a more generic route such as post /upload/:stuff earlier in your routes file and (5) that your that the controller and action you're targeting exist. Hope that helps!
@NizarBlond I'm with you-- all .native does is send the provided query object directly to mongodb.
NizarBlond
@NizarBlond
yes so it you're implying that it doesn't serve me to get listof collections

naturally, this is how I would do it:

mongoose.connection.on('open', function (ref) {
console.log('Connected to mongo server.');
//trying to get collection names
mongoose.connection.db.collectionNames(function (err, names) {
    console.log(names); // [{ name: 'dbname.myCollection' }]
    module.exports.Collection = names;
});

})