sails.js

Waterline Transaction through sails-orientdb

帅比萌擦擦* 提交于 2019-12-11 10:57:31
问题 I'm using transaction in the following code, can I enhance this code furthermore? var db = itemsModel.getDB(); var trans = db.begin(); trans.update('items') .set({status:UNAVAILABLE}) .where({id:items_ids_list,status:AVAILABLE}).exec() .then(function(items){ if (items.length != items_ids_list.length) { trans.rollback(); /* send error here*/ } else trans.commit(); }); 来源: https://stackoverflow.com/questions/29586175/waterline-transaction-through-sails-orientdb

sending mail in cloud9.io

一笑奈何 提交于 2019-12-11 10:40:01
问题 I am running a sails.js project using nodemailer locally which is working well.Nodemailer use Smtp and Gmail's service.Problem is when i transfer my project on cloud9 it is blocking mail. smtpTransport = nodemailer.createTransport('SMTP', { host: 'smtp.gmail.com', port: 25, service: 'Gmail', auth: { user: model.sender, pass: model.password } }); here is configurations and error is: { [Error: connect ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'connect', stage: 'init' } from

Use And in Waterline

微笑、不失礼 提交于 2019-12-11 10:17:11
问题 This is my query using waterline var queryObject = { where: { or: [ {firstName: {'contains': search}}, {lastName: {'contains': search}}, {email: {'contains': search}}, ], and: [ {authType:'google'}, {dealershipcompany: 11} ] } } yet adding 'and' return an error: error: Sending 500 ("Server Error") response: Error (E_UNKNOWN) :: Encountered an unexpected error : ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right

Memory buffers fills up when I stream upload a file, though passing a disk storage location param

£可爱£侵袭症+ 提交于 2019-12-11 10:07:23
问题 Trying to stream-upload to S3 using skipper and skipper-s3 using this code image_upload : function (req,res) { // depends on bodyparser:skipper in confing/http.js console.log("Uploading image .. "); req.file('image') .upload({ adapter: require('skipper-s3'), key: KEY, secret: SECRET, bucket: 'mybucket', tmpdir: 'tmp/s3-multiparts' }, function whenDone(err, uploadedFiles) { if (err){ return res.negotiate(err); } else { dict = { files: uploadedFiles, textParams: req.params.all() } return res.ok

Sails disable criteria for REST in GET

允我心安 提交于 2019-12-11 09:44:03
问题 I have implemented passport-local strategy and passport-bearer strategy. When user logins with username/password credentials, I generate JSON Web Token which returns to requester. On each request I get access_token from query, decode this token from JWT to object and make bearer authorization implemented in /api/policies . And all auth works fine. But when I provide this access_token to RESTful route i.e. user I got empty array. The problem, that Sails accepts access_token as criteria.

Error when use forever in sails

别说谁变了你拦得住时间么 提交于 2019-12-11 09:34:44
问题 I'm a newbie in sails. I found some error when I run sails app by using ' forever start app.js --prod ' my style was broken and there is one error in console, WebSocket connection to 'ws://192.168.1.191/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=hFy1TK_-48EQBVIyAAAE' failed: Error during WebSocket handshake: Unexpected response code: 400 But when I run sails by ' sails lift ', it normally work. And

Sails.js many-to-many associations throw error on create and populate

这一生的挚爱 提交于 2019-12-11 09:17:04
问题 When I try to associate one collection with another collection using a many-to-many association, I get the following error: Using sails-mongo: TypeError: Cannot read property 'where' of undefined at _afterFetchingJunctorRecords (/Users/grant/Sites/sails/test/node_modules/sails-mongo/node_modules/waterline-cursor/cursor/populateBuffers.js:131:35) at /Users/grant/Sites/sails/test/node_modules/sails-mongo/lib/collection.js:103:5 at /Users/grant/Sites/sails/test/node_modules/sails-mongo/node

How do I update a specific key inside a MongoDB sub-document using Sails.js & Waterline?

邮差的信 提交于 2019-12-11 08:39:59
问题 I face an issue when trying to update a single key inside a MongoDB sub-document using Sails.js and the Waterline ORM. This is what my person.js model looks like: module.exports = { attributes: { name: { type: 'string', required: true }, favorites: { type: 'json', defaultsTo: { color: null, place: null, season: null } } } } Now, let's say I want to update a specific person's name and favorite season from my controller, I am doing this: Person.update({ id: '1' }, { name: 'Dan', favorites: {

When i use Waterline's create method, it doesn't return the new record's ID

为君一笑 提交于 2019-12-11 08:27:38
问题 When i create a new record using Waterline's create method, the created object is returned, but without it's ID. How can I get the id of the last inserted object? I'm using the mysql adapter on mariadb if it makes any difference 回答1: It seems like you're probably doing something wrong. I have not done any additional configuration to waterline, anyway it returns id every time when I use new query as well as record at all. In most cases I don't create id field in sails model, auto-generation

How to get the primary key attribute name of a model? (waterline ORM)

六眼飞鱼酱① 提交于 2019-12-11 08:15:58
问题 Some of my models do not have id as their primary key, and I need to know the name of the primary key of a given model but I couldn't find a way of doing this. I searched in the waterline docs and source, but all what I found in the their source is that they are using the attributes object definition which is stored in a unaccessible variable in the lib scope. The "cleaner" way I found to do it for now is like this: // file: api/libs/model.js module.exports = { //... primaryKeyName: function