sails.js

Push values into array of mongodb database through (sails js) waterline

寵の児 提交于 2019-12-21 04:46:08
问题 node js,sails js,waterline. I need to update(or push) values into the below schema after insert I am using sailsjs with waterline and mongodb. { "countries": { "states": [ { "statename": "state", "districts": [ { "distname": "district", "cities": [ { "cityname": "Hyderabad", "places": [ { "placename": "hitechcity" } ] } ] } ] } ] } } I need to know how to update it i need something like this after update { "countries": { "states": [ { "statename": "state", "districts": [ { "distname":

SailsJS: How to properly unit test controllers?

╄→гoц情女王★ 提交于 2019-12-21 04:16:07
问题 Been working with Sails.js and was having trouble coming up with Jasmine unit tests for a controller. If this is something obvious, please pardon my ignorance, as I've only been deep-diving into JavaScript development for the past 3-4 months. In past frameworks (specifically ASP .Net MVC), we had libraries to mock out any dependencies a controller might have to, say, an external service (via dependency injection). I kind of wanted to achieve the same level of unit testability with Sails.js so

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

余生长醉 提交于 2019-12-20 19:14:31
问题 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

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

三世轮回 提交于 2019-12-20 19:14:30
问题 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

Why doesn't .add() insert value in the column?

扶醉桌前 提交于 2019-12-20 07:37:44
问题 I'm trying sails.js association using one way reference (according to sails.js in action book). Now, the value of owner is successfully inserted in owner column, but value in cars column is not inserted. When I tried console.log(foundDriver) and console.dir(foundDriver) , it showed following things: { id: 1, Name: 'asdf' } { cars: [Getter/Setter], id: 1, Name: 'asdf' } My tables (1: driver , 2: car ): CODE: Car.js module.exports = { connection: 'mysqlAdapter', tableName: 'car', attributes: {

How to get data from other table using a column data from a different table?

只愿长相守 提交于 2019-12-20 07:22:15
问题 I have two tables: table1 id | email 1 | email1 2 | email2 table2 userid | username 2 | user1 3 | user2 Now, using sails.js associations, I want to do this: I have a username = user1 . Using this, first I need the userid of this user1, then using this userid, I want to access the email from table1 . I want to do this using models, controllers and associations only. Is it possible? EDIT: The tables I have provided above are sample tables for my original tables. Here I'm posting my actual

Sails.io.js io.socket.get('/user',…) Not implemented in core yet

不问归期 提交于 2019-12-20 06:21:49
问题 Create e.g. assets/js/dependencies/app.io.js with: io.socket.on('connect', function socketConnected() { console.debug("This is from the connect: ", io.socket); console.debug("WebSocket is connected:", io.socket.isConnected()); io.socket.get('/user', function(resData) { console.debug(resData); }); }); Console |> Now connected to Sails. \___/ For help, see: .... (using sails.io.js browser SDK @v0.13.7) app.io.js:3 This is from the connect: SailsSocket {headers: undefined, eventQueue: Object,

How to get current socket object or id with in a sails controller?

筅森魡賤 提交于 2019-12-20 03:57:31
问题 I would like to access the currently connected socket id with in a sails.js (v0.12 ) controller function. sails.sockets.getId(req.socket); is showing undefined since this is not a socket request My objective is to set the online status of my user in the database when he logged in successfully login: function (req, res) { Util.login(req, function(){ var socketId = sails.sockets.getId(req.socket); console.log('socketId ===', socketId); // return undefined }); }, Basically i would like to access

ObjectID not storing hexadecimal value

萝らか妹 提交于 2019-12-20 03:21:16
问题 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

ObjectID not storing hexadecimal value

谁说我不能喝 提交于 2019-12-20 03:21:16
问题 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