sails.js

$sce:itype Attempted to trust a non-string value in a content requiring a string: Context: resourceUrl

不打扰是莪最后的温柔 提交于 2019-12-05 00:43:37
问题 I want to play songs stored in my sails server. Path is http://localhost:4000/images/123.mp3 . In front end, i'm using ng-repeat to list that songs from server. <div ng-repeat="tones in ringTones track by $index"> <div> <i ng-show="playpause" class="fa fa-play-circle" ng-click="playpause=!playpause" onclick="plays(event);"><audio id="audio_{{$index}}" ng-src="tones.tonePath"></audio></i> <i ng-show="!playpause" class="fa fa-pause" ng-click="playpause=!playpause" onclick="stop(event);"></i><

Setting selected item in angular md-select with multiple option

独自空忆成欢 提交于 2019-12-04 23:16:21
Setting selected item in angular md-select with multiple option <md-select multiple ng-model="Reg.roles" placeholder="Please select roles" required> <md-option ng-repeat="role in roles" value="{{role.value}}" ng-selected="{{ role.value === '<%= data.roles %>' ? 'true' : 'false' }}">{{ role.name }}</md-option> </md-select> in my controller $scope.roles = [{ "name": "Account Admin", "value": "account_admin" }, { "name": "Developer", "value": "developer" }, { "name": "Analyst", "value": "analyst" } ]; in view data.roles contains value: ['account_admin', 'developer'] I need the item corresponding

Cannot unit test my model in sailsjs

早过忘川 提交于 2019-12-04 22:50:03
问题 For my sails app I'm using the following code to unit test the User model but got the error message: 'TypeError: Object # has no method 'create'' var User = require('../../api/models/User'); var Sails = require('sails'); console.log(User); describe("User Model:", function() { // create a variable to hold the instantiated sails server var app; // Global before hook before(function(done) { // Lift Sails and start the server Sails.lift({ log: { level: 'error' }, }, function(err, sails) { app =

SELECT and UPDATE multiple records in oriento / orientjs and transaction in waterline

六月ゝ 毕业季﹏ 提交于 2019-12-04 22:11:42
How can I select or update multiple records in oriento? Like in waterline we can offersModel.update({id:items_ids,status:INACTIVE},{status:ACTIVE}) But in waterline transaction is not available. So I want to use : var db = offersModel.getDB(); var trans = db.begin(); trans.update('offers') .set({status:INACTIVE}) .where({id:items_ids,status:ENM.SELLING_STATUS.ACTIVE})//.exec() .then(function(offers){ if (offers.length != items_ids.length) {trans.rollback(); /* send error here*/} else trans.commit(); }) Thanks. Try this db.update(id).set({status:INACTIVE}).scalar() Have you tried following? db

picture do not show in sails.js view

假如想象 提交于 2019-12-04 20:31:52
My assets folder : assets | images | media | book | pictures i want to create new book when i upload book picture in above path, But when i try to show this image in view, the image can not be displayed and there is no error either. my code is: //BookController create: function (request, response, next) { var title = request.body.title; var subject = request.body.subject; var brief = request.body.brief; var author = request.body.author; var origin_pic_name = null; request.file('pic').upload({ dirname: '../../assets/images/media/book/pictures/', },function (err, file) { if(err) console.log(err)

How to translate models in Sails.js?

余生颓废 提交于 2019-12-04 19:54:58
I'm working on a simple app with a few models which need to have multilingual attributes. E.g., a model "Article" with a "title" string attribute should have translation for English and French. I'm aware that Sails.js ships with I18n node module, but that seems to handle hardcoded string translations only. Does anyone have any experience with this or sample code to point me to? I'm looking for a best practice here, if possible. You can do it 2 ways: 1.) Duplicate the fields in you model for each language like: { title_en: "string", title_fr: "string", } 2.) You can add a "language"-attribute

Sails.js Associations many-to-many relation

我的梦境 提交于 2019-12-04 18:42:32
I have a problem with many to many relationship in sails and if somebody can help me it would be great :D I have two models User and Message and the associations is defined as follows api/models/User.js module.exports = { attributes: { messages: { collection: 'message', via: 'owner', dominant: true } } }; api/models/Message.js module.exports = { attributes: { owner: { model: 'user'. via: 'messages' } } }; I checked in the DB (MySQL) the middle table is created and i successfully inserted the data but i cant retrive the data. i start sails console and type User .find() .populate('messages')

Is it possible in Sailsjs to build more complex models

戏子无情 提交于 2019-12-04 18:30:34
问题 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 } } }; 回答1: I don't know if this is still an issue,

Sails.js composite unique field

百般思念 提交于 2019-12-04 18:21:49
问题 This model gives me the effect I want at the expense of duplicated data and general uglyness: //Example var Example = { attributes: { foo: { type: 'string', required: true }, bar: { type: 'string', required: true, }, baz: { type: 'integer', required: true, min: 1 }, foobar: { type: 'string', unique: true } }, beforeValidation : function(values,cb) { values.foobar = values.foo+values.bar; cb(); } }; module.exports = Example; Is there a better strategy for creating a composite unique key? 回答1:

Passing Parameters to sails.js policies

扶醉桌前 提交于 2019-12-04 18:17:27
问题 Sails.js (0.9v) controllers have policies defined as: RabbitController: { '*': false, nurture : 'isRabbitMother', feed : ['isNiceToAnimals', 'hasRabbitFood'] } is there a way to pass params to these acls eg: RabbitController: { '*': false, nurture : 'isRabbitMother(myparam)', feed : ['isNiceToAnimals(myparam1, myparam2)', 'hasRabbitFood(anotherParam)'] } This may lead to multiple use of these functions for different params. Thanks Arif 回答1: The policies are middleware functions with the