waterline

Multiple model updates in sails waterline

杀马特。学长 韩版系。学妹 提交于 2019-12-08 13:50:48
问题 I'm building a project on sails (0.10.0-rc5) for a few days and in a few cases i need to update multiple entries at once with the same data so I made something up ... Servers.find({owner_id: anonymous_user.id}).exec(function(error, servers) { catches.error(error); queries.save_each(servers, {owner_id: user.id}); }); The interesting part is queries.save_each() which I created ... /** * Save each ActiveRecord objects with the desired attributes * @param {object} objects ActiveRecord object (e.g

Waterline (Sails.js): AND conditions

百般思念 提交于 2019-12-08 04:14:17
问题 I'm using mongodb with sails.js querying a model that contains the titles of torrent files. But I'm not able to perform a waterline query using the "AND" condition. I've already tried it in several ways but most of them return empty or simply, never return. e.g. the database contains an entry with: "title": "300 Rise Of An Empire 2014 720p BluRay x264-BLOW [Subs Spanish Latino] mkv" When adding each query parameter line by line: var query = Hash.find(); query = query.where({ "title": {

Waterline MongoDb (populated) fetched object looses its type AND prototype functions

主宰稳场 提交于 2019-12-08 02:13:51
问题 I'm using sails with mongo db over waterline. Lets say that I declare 2 models in my sails project like so : A user model @ models/User.js simplified: username: { type: 'string', unique: true }, passports: { collection: 'Passport', via: 'owner' }, aUserFunction: function(){ console.log('I'm a user function'); } and a passport model @ models/Passport.js simplified: password: { type: 'string' }, owner: { model: 'User', required: true }, aPassportFunction: function(){ console.log('I'm a passport

Deploying a NodeJS App to Azure Websites fails on installing NPM packages from pagages.json from deploy.cmd?

北战南征 提交于 2019-12-07 20:16:29
I'm trying to push a local GIT repository to my Azure Website using .deployment & deploy.cmd. The problem is that when the script tries to install NPM packages it fails after about half is installed. I have tried a lot of things but can't get it to work. I would appriciate if any of you have any idea of why this is not working? This is my code: package.json { "name": "api", "private": true, "version": "0.1.0", "description": "Backend API", "keywords": [], "main": "app.js", "repository": "", "author": "Frej (frej@example.com)", "license": "", "scripts": { "start": "node app.js", "debug": "node

How to count association size with waterline/sails?

只谈情不闲聊 提交于 2019-12-07 13:33:20
问题 Using sails 0.10.5/waterline 0.10.15: I cannot find an answer to a simple question: how to count the elements of an association without using populate() (which would load all data). Let take a simple many2many relation with via: User: attributes: { following: { collection: 'user', via: 'follower', dominant: true }, follower: { collection: 'user', via: 'following' } Now I need the size of the collections. Currently I try User.findById(1).populateAll().exec(function(err, user) { // count of

get Selected fields in .populate() waterline-postgresql .populate('fieldName',{select:[]})

空扰寡人 提交于 2019-12-07 12:44:46
问题 select query is not working in .populate() of waterline-postgresql. Model.find(query).populate(assoc.alias,{select:['field1','field2']}); This is not working in waterline-postgresql adapter. Is this not supported or Am I making any mistake? 回答1: select is not supported in .populate(). You can see this github issue. In populate select is not working currently. This is feature request and it is open issue. hope in next release waterline team will introduce this feature. 回答2: Since there's no

Can't find records in Waterline by date/time

半世苍凉 提交于 2019-12-07 09:36:29
问题 how compare a datetime in sails.js Model? here it is what i did but without luck. var _date = moment().format('YYYY-MM-DDTHH:mm:ss.SSS') + 'Z'; Game.find({ where:{ active: true, start: { '>=' : _date } }, limit: 1, sort: 'start asc' }, function(err, game) { console.log('ERROR: ' + err); console.log('Game OBJ' + game.toString()); }); 回答1: The datetime type is transformed into an actual Javascript date in Waterline (the Sails ORM). So it needs to be compared against a date object, not a string.

Sails.js + Waterline: Many-to-Many through association

 ̄綄美尐妖づ 提交于 2019-12-07 03:09:31
问题 I'm new to Sails.js (v0.10.5) and Waterline ORM. I have 3 tables in database: users (id, name), roles(id, alias) and join table users_roles(user_id, role_id). It's important not to change table names and field names in database. I want Policy entity to be a join entity between User and Role. Here is some mapping code: //User.js module.exports = { tableName: 'users', autoCreatedAt: false, autoUpdatedAt: false, attributes: { id: { type: 'integer', required: true }, name: { type: 'string' },

how to use the attribute type like 'array' and 'json' in sails

為{幸葍}努か 提交于 2019-12-07 00:54:05
问题 Sails have support very convenient model througth Waterline, and I have used the 'array' attribute type in the way storing many string, but now I want to store more complex object, Although I can store the raw data in mongo by 'array' type, I don't know if it is safe and I want define the object type in the array, like mongoose's style. for example, I need a model "Products" and I want define it as a 'array' but the object stored in the array only model "Book", what I can do like this, but I

Sails.js Associations many-to-many relation

丶灬走出姿态 提交于 2019-12-06 13:43:36
问题 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