waterline

Sail.js multiple connections on start

六眼飞鱼酱① 提交于 2019-12-11 03:04:00
问题 I've got an odd problem - on start of my sails app (which is connecting with postgres and deployed on heroku ) there are multiple connections (around 10) to database, and since it's free account, if I then try to launch app on localhost to test some new code I get an error "too many connections for a role". So does anyone know why there are so many connections to database and can I change it, to have only one connection per app? EDIT: Error creating a connection to Postgresql: error: too many

How to create a new instance of a model in sailjs?

亡梦爱人 提交于 2019-12-11 02:24:01
问题 I want to create a not persisted new instance from a model, populate some attributes and send it back as a JSON response from a controller action. In rails it's pretty simple to get a new instance of a model with Model.new , but how can I do that with waterline or sails.js ? If you are familiar with rails: Model.new -> Creates a new instance of a model. How can I do this in Sails.JS? Model.create -> Creates a new instance of a model, which is (already) persisted. I've already checked the

Can we change the value of attribute on after/before Create() callback in sails?

China☆狼群 提交于 2019-12-10 19:57:41
问题 I have a scenario where I have to populate attribute of model with its id. For eg.. In User model: module.exports = { attributes: { activation_link: "string" }, afterCreate: function(value, cb) { value.activation_link = "localhost:1337/user/action/"+ value.id; cb(); } The activation_link's modified value has to saved in the database too. How can that be achieved? 回答1: According to this and this your code should actually work: your manipulations in afterCreate are supposed to mutate the

How do I perform this query using sailsjs ORM (waterline)

穿精又带淫゛_ 提交于 2019-12-10 19:57:05
问题 How do I perform this query? SELECT * FROM blog GROUP BY MONTH(createdAt) What I've tried: Blog.find() .groupBy({MONTH:'createdAt'}) .exec(function(err,months){ res.view({ layout: 'blogLayout', archive:months }); }); Gives me Error: Cannot groupBy without a calculation 回答1: Waterline (the ORM used by sails) at this point only supports using groupBy in combination with sum(), count() etc. You can find the line of code that verifies this here: https://github.com/balderdashy/sails-mongo/blob

Step by Step guide to using a migrating tool for production SailsJS system

余生长醉 提交于 2019-12-10 18:53:52
问题 I very new to production sailsjs environment, I need a way to add table changes which I make in my sailsjs Models in Dev to be applied to Sailsjs Production Models. Does anyone dealt with this before ? Can someone guide me through it please ? It would be really helpful to have a step by step guide, All i need is to have the Model attributes created in the Production database tables. 回答1: Well you can always jump in here: https://gitter.im/balderdashy/sails and you might find some help. 来源:

Fetch results from model in Waterline if property is defined

做~自己de王妃 提交于 2019-12-10 14:22:03
问题 I've got a model where not every property is required. I'd like to query the model and return all instances where the property is defined. Here's what I think the code should look like, but it doesn't work. Any ideas or links to some detailed documentation? MyModel.find() .where({ "propertyThatMayExist" : { "!=" : undefined } }); Thanks a bunch in advance! 回答1: The easiest way would be to test against null . The correct operator is ! or not : MyModel.find().where({propertyThatMayExist: {'!':

Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from deploy.cmd?

房东的猫 提交于 2019-12-10 11:37:21
问题 I'm trying to push a local GIT repository to my Azure Website using .deployment & deploy.cmd. The problem is that when the script tries to install NPM packages it fails after about half is installed. I have tried a lot of things but can't get it to work. I would appriciate if any of you have any idea of why this is not working? This is my code: package.json { "name": "api", "private": true, "version": "0.1.0", "description": "Backend API", "keywords": [], "main": "app.js", "repository": "",

How can I add an instance method to all Models in sails.js?

半世苍凉 提交于 2019-12-10 02:04:38
问题 I'd like to add a default toDisplay function to all models which will use metadata, not unlike attribute/association definitions, to perform manipulations on the instance's attributes/associations making them suitable for display in the UI. for example: Foo.findOne(someId) .exec(function(err, foo) { ... res.view({ foo: foo.toDisplay(), }); }); So, I'd like to add this function too all models. I can imagine a Model.prototype.toDisplay = ... solution, but I'm not sure where to get Model from

Sailsjs Geospatial Solution with Waterline

喜你入骨 提交于 2019-12-08 19:25:06
问题 It seems like Sailsjs/Waterline does not currently support a POINT type or geospatial indexing with JSON. Are there any ways to customize a schema for certain adapters to support geospatial datatypes? If not, is there a way to integrate a second ORM into Waterline that does so? 回答1: In Sails.js, you need MongoDB (npm install --save sails-mongo) for geospatial indexing, plus you need to ensure the 2dindex gets created in config/bootstrap.js as such (make sure to replace modelname and

Select specific fields from database

岁酱吖の 提交于 2019-12-08 15:16:51
问题 I just want to know that is it possible to select specific fields using waterline, orientdb query is given below. e.g. select phone from user I want to select phone from user vertices by using this query userModel.find(phone) .then(function(phonelist){ if(!phonelist) console.log('msg: RECORD_NOT_FOUND'); else console.log(phonelist); .catch(function(err){ console.log('err: 'err'); }); 回答1: Yes, it's possible, you just need to add select to your search criteria, for example (assuming you are