sails.js

Stop the auto migration of the schema in the sails.js

徘徊边缘 提交于 2019-11-29 09:53:48
In sails.js , how can we stop the automigration of the schema into the database. Sometimes,it gives error due to the migration. Is there a way that we can make the migration run only when the application is deployed? JohnGalt You can also try something like this: module.exports = { // migrate: 'alter', // adds and/or removes columns on changes to the schema // migrate: 'drop', // drops all your tables and then re-creates them. All data is deleted. // migrate: 'safe', doesn't do anything on sails lift- for use in production. attributes: { /* ... */ } }; Luja Shrestha We can achieve that by

Handling database environment configuration in Sails.js

血红的双手。 提交于 2019-11-29 09:39:04
问题 The issue I have is related to the following quote from the official documentation: Note If any connection to an adapter is used by a model, then all connections to that adapter will be loaded on sails.lift, whether or not models are actually using them. In the example above, if a model was configured to use the localMysql connection, then both localMysql and remoteMysql would attempt to connect at run time. It is therefore good practice to split your connection configurations up by

npm install not installing things at /usr/bin

余生长醉 提交于 2019-11-29 07:46:39
I am trying to install SailsJS with: $ sudo npm install -g sails It works, install everything at /home/brunoluiz/npm/lib/node_modules/sails with the following log: /home/brunoluiz/npm/bin/sails -> /home/brunoluiz/npm/lib/node_modules/sails/bin/sails.js sails@0.9.16 /home/brunoluiz/npm/lib/node_modules/sails ├── connect-flash@0.1.1 ├── pluralize@0.0.5 ├── inflection@1.2.5 ├── grunt-sails-linker@0.9.5 ├── grunt-contrib-clean@0.4.1 ├── node-uuid@1.4.0 ├── async@0.2.9 ├── grunt-contrib-concat@0.3.0 ├── grunt-contrib-copy@0.4.1 ├── grunt-contrib-coffee@0.7.0 ├── ejs-locals@1.0.2 ├── ejs@0.8.4 ├──

Change field name for CreatedAt / UpdateAt Attributes

陌路散爱 提交于 2019-11-29 06:45:21
问题 I am attempting to model an existing MSSQL table in SailsJS. Unsurprisingly the tables in the existing database have a createdAt and updatedAt column similar to what is generated by the SailsJS framework. Is there a way to assign the value of the property generated by the SailsJS framework to an attribute that I have defined? For example: attributes: { ... creationDate:{ columnName:'cre_dt', type:'datetime', defaultsTo: this.createdAt } ... } 回答1: No, but you can turn off the auto-generated

How to selectively populate waterline associations via query param in sails.js

耗尽温柔 提交于 2019-11-29 06:22:18
问题 By default, sails will populate all relationships within a model when it's corresponding API route is hit. Does anyone know if it's possible to toggle this functionality? If I'm working with a one-to-many association, I may not want to populate the association when doing a listing of all items for performance reasons. But when viewing a single item, it would be nice to complete the population. For example, say one ticket can have many comments. I don't care about the comments when fetching a

Using Waterline model outside SailsJS api

谁都会走 提交于 2019-11-29 03:42:25
Is it possible to use models defined within [app-name]/api/models outside api folder? I have created separate folder in application root, where I placed cron job that should fill my database every hour. I would like to reuse Models defined inside my api folder, but not sure how to do it. I see that I can do sails.lift inside that cron script but that doesn't seem very nice to me. Did someone experience something similar? I'm new to node.js, so maybe I'm missing something pretty obvious. If your concern with using sails.lift is that it starts an actual HTTP server that listens for requests, you

Sails.js query on an associated value

送分小仙女□ 提交于 2019-11-29 02:56:36
问题 I'm using Sails.js version 0.10.0-rc4 . All models are using sails-mysql. I'm trying to query a model which has an "one-to-many" association to another model (the query is happening on the "many" side). It looks something like this: Post.find() .where({ category: category_id }) .populate("category") .exec( ... ) This gives me an empty array back however when I leave out the .populate("category") I get the correct result set. I know that I could leave .populate("category") out and then fetch

How to perform SQL Joins and Relations in Sails.js and Waterline?

时光毁灭记忆、已成空白 提交于 2019-11-29 02:11:06
问题 Can anyone guide me on how to setup relational schema & performs joins in sails.js? 回答1: Associations are officially Supported in Waterline Overview From the docs: With Sails and Waterline, you can associate models across multiple data stores. This means that even if your users live in PostgreSQL and their photos live in MongoDB, you can interact with the data as if they lived together in the same database. You can also have associations that span different connections (i.e. datastores

How to serve a bootstrap template in sails 0.9?

China☆狼群 提交于 2019-11-29 01:37:59
I wanted to know how to serve a bootstrap template through newer sails version . Should I update the links of JS to something else . I tried moving js and images in asset folder but javascript didn't work . The sails documentation is very poor on this topic . Can anyone tell a easy way to integrate it . Thanks in advance Sails 0.9.x has moved to use Grunt for handling assets. This allows you to do many different kinds of pre-compilation and asset handling. By default, automatic asset injection into your views and layouts is not available. We have added a flag you can include when generating a

How do I convert an image to a base64-encoded data URL in sails.js or generally in the servers side JavaScript?

流过昼夜 提交于 2019-11-29 01:06:13
I am making a small app in sails.js and I need to store images in database. For that, I need to convert an image to a base64-encoded data URL so that I can save it as a string in my sails models. However, I don't know how to convert it in this form. All the older questions asked about converting an image to base64-encoded data URLs, and they answer this about doing it on the client side. However, I want to do it on the server side while I will be getting the image through a post request. How can I achieve this? As I understand you want to convert a file into base64 encoded string. Whether the