waterline

Transactional SQL with Sails.js

心不动则不痛 提交于 2019-12-03 03:23:09
So I have been playing with NodeJS/Express for a little with now and I would really like to try to rewrite a relatively large side project using a full JavaScript stack just to see how it will work. Sails.js seems to be a pretty good choice for a NodeJS backend for a REST API with support for web sockets which is exactly what I am looking for however is one more issue I am looking to resolve and that is transactional SQL within NodeJS. Most data layer/orms I have seen on the NodeJS side of things don't seem to support transactions when dealing with MySQL. The ORM provided with Sails.js

npm install not installing latest version on GitHub

你离开我真会死。 提交于 2019-12-02 17:55:09
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 in the one being updated "dependencies": { "async": "0.2.10", "underscore": "1.5.2", "underscore

Sails blueprints lifecycle

风流意气都作罢 提交于 2019-12-02 14:08:21
问题 I need to add some additional data to result of find blueprint. I found this solution: module.exports = { find: function(req, res) { return sails.hooks.blueprints.middleware.find(req, res); } } but I can`t find any way to change response here, or add callback into the blueprint. I even try to change blueprint and add the cb in it: module.exports = function findRecords (req, res, cb) { ... if (typeof cb === 'function') res.ok(cb(result)); else res.ok(result); but in this case it returns 500

Sailsjs Mysql ORM multiple query on the same table field

本小妞迷上赌 提交于 2019-12-02 11:32:49
问题 Im using sails v 0.10.5 and latest sails-mysql I have a Restaurant filtering system Venue.find().populate('comments', { deleted: false }).where({ restaurant_services: {contains: '"delivery":1'}, restaurant_services: {contains: '"takeout":1'}, restaurant_specialties: {contains: '"breakfast":1'} }) Now the problem is when I get the data from the client, I do not know how many items the user has selected for restaurat_services, so obviously I have to create a dynamic JSON object for the .where()

Nested Models and controllers in sails are not working Policies

匆匆过客 提交于 2019-12-02 07:24:13
问题 Continuation of this bug : API Versioning in SailsJS Sails Permissions AuditPolicy is not working properly. can any one guide me to do. O/P: error: Sending 500 ("Server Error") response: Error: Invalid route option, "model". I don't know about any models named: `v1/user` at Object.module.exports.parseModel (E:\demo- server\node_modules\sails\lib\hooks\blueprints\actionUtil.js:266:25) at ModelPolicy (E:\demo-server\node_modules\sails-permissions\api\policies\ModelPolicy.js:8:42) at

Sailsjs Mysql ORM multiple query on the same table field

岁酱吖の 提交于 2019-12-02 04:57:38
Im using sails v 0.10.5 and latest sails-mysql I have a Restaurant filtering system Venue.find().populate('comments', { deleted: false }).where({ restaurant_services: {contains: '"delivery":1'}, restaurant_services: {contains: '"takeout":1'}, restaurant_specialties: {contains: '"breakfast":1'} }) Now the problem is when I get the data from the client, I do not know how many items the user has selected for restaurat_services, so obviously I have to create a dynamic JSON object for the .where() function The problem is though, I cannot do this var searchObj = {}; searchObj['restaurant_specialties

Sails.js - Is there intended support for a “one-way-many” association

≡放荡痞女 提交于 2019-12-02 01:40:12
I'm interested in a one-way-many association. To explain: // Dog.js module.exports = { attributes: { name: { type: 'string' }, favorateFoods: { collection: 'food', dominant: true } } }; and // Food.js module.exports = { attributes: { name: { type: 'string' }, cost: { type: 'integer' } } }; In other words, I want a Dog to be associated w/ many Food entries, but as for Food , I don't care which Dog is associated. If I actually implement the above, believe it or not it works. However, the table for the association is named in a very confusing manner - even more confusing than normal ;) dog

JSON stringify in Node JS not serializing array of objects

寵の児 提交于 2019-12-02 01:28:58
问题 I am using sails.js (node js framework). I am trying to JSON.stringify one of the objects, but when I do that it omits one of the fields (rooms array below). Here is what console.log(object) gives me: [ { rooms: [ [Object], [Object] ], state: '53df76c278999310248072c6', name: 'Sydney Center', menuItems: null, createdAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), updatedAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), id: '53dff0205c89c03428a31cee' }, { rooms: [

ObjectID not storing hexadecimal value

三世轮回 提交于 2019-12-01 22:44:56
Originally, my Sails/Mongo was storing the ObjectID in the database as follows: "_id" : ObjectId("557077fb836bdee256004232") Not sure what changed or happened, but now new records are being stored as follows: "_id" : { "_bsontype" : "ObjectID", "id" : "UtÓ-Åß\u0010C&5", "generationTime" : 1434552692 } This is only occurring in 2 developer environments out of 6. Things I've checked: Reverted to a stable commit from last week, cleared node_modules, npm cache, etc. Re-installed and no luck. Re-installed Node/npm/MongoDB completely to ensure I'm on the latest stable version of everything... my

JSON stringify in Node JS not serializing array of objects

我们两清 提交于 2019-12-01 21:43:20
I am using sails.js (node js framework). I am trying to JSON.stringify one of the objects, but when I do that it omits one of the fields (rooms array below). Here is what console.log(object) gives me: [ { rooms: [ [Object], [Object] ], state: '53df76c278999310248072c6', name: 'Sydney Center', menuItems: null, createdAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), updatedAt: Mon Aug 04 2014 23:42:08 GMT+0300 (Jerusalem Summer Time), id: '53dff0205c89c03428a31cee' }, { rooms: [ [Object], [Object], [Object] ], state: '53df76c278999310248072c6', createdAt: Mon Aug 04 2014 23:43:21