sails.js

Sails.js model - insert or update records

走远了吗. 提交于 2019-12-03 12:25:15
Been trying out Sails.js and I'm writing an app that imports data from a third-party API and saves in into a MySQL table. Basically I'm trying to sync data over to my app for further analysis, updating my records or creating new records as needed. I've looked through Sails' API and I see methods to find, create and update records but no built-in method to insert/update records based on the situation. Did I overlook something, or will I need to implement this myself? If I have to implement this myself, does anyone know of a good design pattern for insert/update? This is what I think it might

Is it possible in Sailsjs to build more complex models

杀马特。学长 韩版系。学妹 提交于 2019-12-03 12:12:59
I would like to have arrays or collections in my model, is this yet possible with waterline (mongoDB)? are there any alternatives around? example: { name: Bundle, col1 : { name : anOtherModel, subCol: { text: aString, ... } }, col2 : { name : anOtherModel, subCol: { text: aString, ... } } } to: module.exports = { attributes : { name : { type : 'STRING', required : true }, basicModules: { type : 'ARRAY', // or 'COLLECTION' required : false } } }; I don't know if this is still an issue, but the trick is to neither POST as "form-data" nor "x-www-url-encoded". You have to POST the "raw" content:

Authentication methods over sockets

此生再无相见时 提交于 2019-12-03 11:32:58
问题 I'm trying to get authentication working over sockets with sailsjs and passport . The challenge seems to be the fact that a socket connection doesn't have a session, and that sailsjs mocks a request object, causing it to not have Passport middleware setup. This caused nodejs to throw an error, saying that the req object didn't have a method called logIn . So, I've tried following the code snippet as provided by @xdissent here: Sails.js + Passport.js authentication through websockets which,

Using TypeScript with Sails

爱⌒轻易说出口 提交于 2019-12-03 11:29:21
Is anyone using TypeScript with Sails? If so, what are you using for external declarations? I am in the middle of a Sails application project and learned about TypeScript. I am trying to determine if TypeScript is something I should pursue for this project. Any info will be appreciated. Thanks. from : https://github.com/balderdashy/sails Sails is built with node connect express and socket.io . This means that definition files for these libraries are what you need. All of these are available from the Definitive TypeScript definition repository : https://github.com/borisyankov/DefinitelyTyped .

How to Log in SailsJS

被刻印的时光 ゝ 提交于 2019-12-03 10:34:01
What is the actual syntax to log in SailsJS? Docs don't have anything, but found the following line in the site's roadmap "Pull out Sails.log (winston wrapper) as a separate module so it can be used by waterline" I image it's something like: Sails.log(...) Sails.error(...) Sails.warn(...) In your controllers, models, services, and anywhere else that the sails global is available, you can log with one of: sails.log(); sails.log.warn(); sails.log.info(); sails.log.debug(); sails.log.error(); sails.log.verbose(); sails.log.silly(); The logging level (that is, the level at which logs will be

SailsJS - using sails.io.js with JWT

十年热恋 提交于 2019-12-03 07:16:27
I have implemented an AngularJS app, communicating with Sails backend through websockets, using sails.io.js. Since the backend is basically a pure API and will be connected to from other apps as well, I'm trying to disable sessions completely and use JWT. I have set up express-jwt and can use regular HTTP requests quite nicely, but when I send a request through sails.io.js, nothing happens at all - websocket request keeps pending on the client, and there's nothing happening on the server (with "silly" log level). I've tried patching sails.io.js to support the query parameter , and when

how to call default blueprint actions in a custom overridden one?

拥有回忆 提交于 2019-12-03 06:52:37
SailsJS provides default blueprint actions, such as find, update, create, etc. I need to override some of them to suit particular business purposes. However, I would like to add to them, instead of simply override them. How to call the default blueprint actions in the overriding action. For example, update can update the record of a model. update I want to have update do more, besides updating the record of a model. In my custom update method, I do not want to duplicate default update. How can I do that? copy everything from PROJECT-ROOT\node_modules\sails\lib\hooks\blueprints\actions to

Emitting socket.io event from Sails.JS and handling it on server using Sails.JS skeleton

我是研究僧i 提交于 2019-12-03 06:07:04
问题 I have a problem in understanding the concept of sending socket.io events from Sails.js client side controller and handling them in server-side controllers. First of all, I have downloaded the SailsJS project skeleton using npm and the structure as follows: Project: api --adapters --controllers ----server_userController.js --models --polices --services assets --[styles, views, images, bower_components, and etc] --js ----controllers ------userController.js ----app.js ----sails.io.js ----socket

npm install not installing latest version on GitHub

帅比萌擦擦* 提交于 2019-12-03 05:33:44
问题 I have a module called 'sails-mongo' and I want to update it to the newest version using the following command: npm update sails-mongo --save I also tried uninstall then install again. I tried sails-mongo@latest and sails-mongo@beta . Problem : The current version ( master ) on GitHub the package.json (https://github.com/balderdashy/sails-mongo/blob/master/package.json) file has: "dependencies": { "async": "~0.2.9", "lodash": "~2.4.1", "mongodb": "1.4.2", "waterline-errors": "~0.10.0" }, And

Sails.js — Accessing local.js environment settings in controllers

我只是一个虾纸丫 提交于 2019-12-03 05:17:40
问题 In production I have AWS credentials stored as heroku config variables. In development I want to include the config details in config/local.js, but how do I access the config details in a controller? local.js contains: module.exports = { aws_key: "...", aws_secret: "..." } In my controller I have tried aws_key , config.aws_key , and others - but no luck. Is there a main app namespace that I can use to scope into the properties exported by local.js? I am new to sails and I feel like this