waterline

sails 0.9.8 not work, when created controller and lift it

£可爱£侵袭症+ 提交于 2019-12-25 06:55:50
问题 I have a problem with sails 0.9.8. I already installed sails on my mac and also lift, it work well, but when start generate controller and model then start lift command again it show some error like: $sails lift /usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/core/index.js:68 var schemaAttributes = this.waterline.schema[this.identity].attributes; ^ TypeError: Cannot read property 'user' of undefined at _.extend._initialize (/usr/local/lib/node_modules/sails/node_modules

Sails 1.0 cannot access autogenerated associated entity routes

孤者浪人 提交于 2019-12-25 00:54:33
问题 I have an association between Client and Budget as follows: //Client.js module.exports = { primaryKey: 'id', attributes: { id: { type: 'number', unique: true, autoIncrement: true }, name: { type: 'string' }, phone: { type: 'string', unique: true }, email: { type: 'string', unique: true }, budgets: { collection: 'budget', via: 'client' }, } }; // Budget.js module.exports = { primaryKey: 'id', attributes: { id: { type: 'number', unique: true, autoIncrement: true }, client: { model: 'client' },

Waterline.js Joins/Populate with existing database

与世无争的帅哥 提交于 2019-12-24 16:44:10
问题 I have an existing postgres database which I am using to build a sails.js driven website, utilising waterline for ORM. I'm fine with using my database in its existing form for everything other than population i.e. joining tables. When working with a non-production database I'm comfortable with how waterline can produce join tables for me, but I'm really unsure how to bypass this to work with the current tables I have and their foreign key relationships. To give an idea of the types of tables

Sails.js How to insert data into a join table (Many to Many)

只愿长相守 提交于 2019-12-24 15:42:31
问题 I am having an error inserting data into my join table and I don't know if I'm doing it the right way. Here are my 2 models that have the many to many association. Commit.js: module.exports = { schema: true, attributes: { idCommit : { type: 'integer', autoIncrement: true, primaryKey: true, unique: true }, revision : { type: 'integer', required: true }, issues: { collection: 'issue', via: 'commits', dominant: true } } }; Issue.js: module.exports = { schema: true, attributes: { idIssue : { type

Sails.js: Nested MongoDB queries

旧街凉风 提交于 2019-12-24 13:24:42
问题 I am using Sails v0.11 and am developing an standalone importer script in order to import data to mongoDB and - that is now the not-working part - build the associations between the models. For this process I introduced temporary helper properties in the models in order to find the associated records and replace them by in real MongoDB _ids. The script starts Sails in order to be able use its features (waterline, etc.): var app = Sails(); app.load({ hooks: { grunt: false }, log: { level:

Sails.JS + MySQL: Unknown column 'NaN' in 'where clause'

混江龙づ霸主 提交于 2019-12-24 12:49:20
问题 this is my first time using sails.js with mySQL database and I'm really confused about this error. I have a controller & model called 'company'. It relates to table 'company' in mySQL database. The table itself has one-to-many associations with two tables called 'module' and 'user' (each user/module must connect with one company id). I've set the foreign key in the MySQL database. The problem is.. each time I open any page/action from this controller, there is this error: error: Sending 500 (

How to use OrientDB in a SailsJS App

走远了吗. 提交于 2019-12-24 11:20:05
问题 I am new to NodeJS and SailsJS, was working with Rails or PHP before. I want to use SailsJS together with OrientDB. What would be the best approach? I found two options so far, but the amount of information isn't that great (yet). Go with Waterline and this sails adapter for orientdb Go one level deeper and use the binary adapter from nodejs Any help, tips, hints would be greatly appreciated. I am a bit lost but very excited to understand more about these great tools. Thanks! 回答1: You

Sails 1.0 Models without primary key

ⅰ亾dé卋堺 提交于 2019-12-24 07:41:48
问题 I try to use new version 1.0 and refactoring my project. I have one problem and i don't now how i can solve her. Some tables on my BD don't have primary keys and when i migrate to sails 1.0, i have this error In model friends : The primary key is set to id , but no such attribute was found on the model. You must define an id attribute in api/Friends.js or in config/models.js . See http://sailsjs.com/upgrading#?changes-to-model-configuration for info Can i use my model without primary keys?

SailsJS: beforeUpdate (Lifecycle callback), access current values

与世无争的帅哥 提交于 2019-12-24 03:26:17
问题 It's clear how to access the new values, the first argument contains them beforeUpdate: function (values, cb) {....} But how can I access the current values, that are to be replaced? 回答1: In order do access current values you will have to make the call and get the current record. models/user.js beforeCreate: function (values, cb) { User.findOne(this.update.arguments[0].id || this.update.arguments[0]).exec(err, function(originalUser){/*...*/}) } Also check out https://github.com/balderdashy

Sails.js/waterline: Executing waterline queries in toJSON function of a model?

非 Y 不嫁゛ 提交于 2019-12-24 03:25:58
问题 I have the following model, let's say it describes a book: module.exports = { attributes: { name: { type: 'String', required: true }, type: { type: 'string', required: true }, book_id: { type: 'integer' } } } Here the 'type' attribute is the genre of the book, for example HorrorBook. I have a separate model for HorrorBooks, FantasyBooks and such, since the structure of the models differs from each other so much, they have fields the other doesn't have etc, which is why I can't just use a