sails.js

Sails.js & MongoDB: duplicate key error index

谁说我不能喝 提交于 2019-12-12 02:33:55
问题 I'm using Sails.js (0.9.8) and MongoDB (via the sails-mongo adaptor) to create a collection of pages that can be positioned in a tree-view. I would like to store the path of a page in an array of UUIDs My model: module.exports = { schema: true, attributes: { uuid: { type: 'string', unique: true, required: true, uuidv4: true }, name: { type: 'string', required: true, empty: false }, path: { type: 'array', required: true, array: true } } } It works well when I save a 'root' page (the 'path'

sailsjs generate dynamic views/ejs files

白昼怎懂夜的黑 提交于 2019-12-12 02:16:36
问题 I'm generating/copying ejs files dynamically and put them in views folder and they work fine in development mode however in production mode it's not reflecting changes until I relaunch sails. How can I make it work in production mode as well? I'm using simple fs create/update file operations to write to ejs file 回答1: Found the solution. Following posts helped me in that: Sailsjs view caching (bug ?) https://github.com/balderdashy/sails/issues/3513 http://expressjs.com/en/api.html The reason

Sails.js: Subscribing a User to specific actions on a Request

情到浓时终转凉″ 提交于 2019-12-12 01:58:46
问题 In my Sails project, I have a User model/controller and a Request model/controller, as well as a Dashboard controller. A user can make a request for data using RequestController.create , and an administrator can approve it using RequestController.grant . What I want to do is to notify a user whenever one of his/her requests is approved (updated). In RequestController.grant , I call Request.publishUpdate(...) , and in my DashboardController.display , I call Request.find(req.session.user.id,

Transaction in orientdb and waterline

无人久伴 提交于 2019-12-12 01:48:54
问题 I am trying to to create transaction in waterline but I am getting this error from OrientDB: com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException: Cannot find a command executor for the command request: sql.BEGIN Here is my code: try { itemsModel.query("BEGIN", function(err) { if (err) {throw new Error(err);} itemsModel.update({id:items_ids,status:ACTIVE},{status:INACTIVE}) .exec(function(err, INA_items){ if (err) {throw new Error(err);} if (INA_items.length != items

How to use association in sails.js + mongodb?

一个人想着一个人 提交于 2019-12-12 01:04:05
问题 In my case fetching data from two collection usind one id to use another id data not coming properly. 回答1: You can use the associations in the Sails.js v0.10. npm install sails@git://github.com/balderdashy/sails.git#v0.10 For the Mongo-db npm install sails-mongo@git://github.com/balderdashy/sails-mongo.git#v0.10 and here is the documentation.. https://github.com/balderdashy/sails-docs/blob/master/reference/ModelAssociations.md 来源: https://stackoverflow.com/questions/21545142/how-to-use

Exits custom Sails 1 and Actions 2

梦想的初衷 提交于 2019-12-12 00:59:39
问题 If I want to return an output with some error with status code and error message in sails 1 using Actions 2. How to do? EX: ... exits: { notFound: { description: 'not found', responseType: 'notFound' } ... How would it be to make an exit? For example: with status code 403 and message "Not allowed" 回答1: EDIT: I tried the naive way and it worked! You can return with a non success exit as a function and pass a json as an argument. Example code: return exits.notfound({ error: true, message: 'The

in sailsjs , 403 “You don't have permission to see the page you're trying to reach” error produce when adding new pages ,controllers and models

时光怂恿深爱的人放手 提交于 2019-12-11 23:45:24
问题 First i run my sails project in local , after i pushed in git repo and then i changed in online and then pushed in remote place. then i downloaded in my local. This changes produce permission problem. that is "You don't have permission to see the page you're trying to reach" this error caused while i was inserting data in mongo. what i should do ? i want get output back 回答1: This is a guess since I'm not sure what your code looks like but I'm guessing you haven't included the following CSRF

Cannot POST forms using Phusion Passenger with Sails.js/Node.js

帅比萌擦擦* 提交于 2019-12-11 20:59:41
问题 I have a site written with Sails.js that I'm trying to deploy to a server with Passenger on it, and so far I'm not having any luck. While all GET requests work, none of the POST requests seem to actually make it to the application. Everything works perfectly without Passenger. Test Controller : module.exports = TestController = show: (req, res) -> res.view() post: (req, res) -> res.send(200) Form : form(action='/test', method='POST') input(type='text', name='test', placeholder='foo') input

using express-device with sails

烂漫一生 提交于 2019-12-11 20:23:41
问题 been trying to play with sails framework as planning to port my express app. The problem I got into was how to make express-device npm package to work with it. In express app I just require module like in this case var device = require('express-device') and then configure it in server.configure. Any help? 回答1: Ok, so I found the solution... After running npm install express-device --save I had to create a express.js module inside of config/ dir and the content of module looks like this:

Sailsjs + vuejs + axios + CSRF tokens

半城伤御伤魂 提交于 2019-12-11 19:31:30
问题 i some thing not understand. Always get an error 403. I have a code in frontend(vue.js), here I get a token _csrf from Sails.js, its ok. axios.get('http://localhost:1337/csrfToken') .then(response => { this.$store.commit('csrf_update', response.data._csrf); console.log("_csrf===",response.data._csrf); axios.defaults.headers.post['X-CSRF-Token'] = response.data._csrf; }) And i have a backend sails.js, settings in security.js cors: { allRoutes: true, allowOrigins: 'http://localhost:8080',