sails.js

addToCollection and set intermediate table column values as well

╄→尐↘猪︶ㄣ 提交于 2019-12-25 03:13:59
问题 I am using Sails v1.1 - Following the example from the "Through" associations on sails - https://sailsjs.com/documentation/concepts/models-and-orm/associations/through-associations They defined a "through" association as basically a custom model. So this really isn't "through", it's just controlling the join table for the many to many relation. So in the intermediate model, I added a custom attribute of isTyping seen below. Is it possible to add to collection and set this intermediate value

sailsjs + ext-direct (sencha extjs)

百般思念 提交于 2019-12-25 02:51:40
问题 I was wondering if anyone has used ext-direct with sailsjs. If you have or anyone with the know how, please can you direct me. Thank you. Here are some examples In regular nodejs/express app, I would normaly do this in my app.js file app.get(ExtDirectConfig.apiPath, function (request, response) { try { var api = extdirect.getAPI(ExtDirectConfig); response.writeHead(200, {'Content-Type': 'application/json'}); response.end(api); } catch (e) { console.log(e); } }); // Ignoring any GET requests

Mongodb find a value inside the array

拜拜、爱过 提交于 2019-12-25 01:32:12
问题 If I have this schema... person = { emails : Array } The values are stored in emails array as mentioned below: emails : [{ a : "a@a.com" , b: "b@b.com" , c : "c@c.com" }] Now i tried the below mentioned queries , Person.findOne({emails : "a@a.com"}).exec(function(err,person){ }); Mongodb native query Person.native(function(err,collection){ collection.find( emails : { "$in" : "a@a.com"} , function(err , result){ //code }); }); EDITED QUESTION Now i tried using OR as below. Person.findOne({ "or

next step after the oauth authentication - sails

泪湿孤枕 提交于 2019-12-25 01:12:30
问题 I have followed this guide in my sails app and everyone seems to be working perfectly fine. when clicking the twitter button on localhost:1337/login page the website redirects the user to the authentication page. when the user accept the terms, the website redirect the user back to server homepage. here it ends, how can i use the twitter data that twiiter Apparently gave me? 回答1: Once the user is authenticated in third-party service, he will be redirected back to your website together with

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' },

CSS issues with html-pdf

泪湿孤枕 提交于 2019-12-24 22:53:52
问题 I want to use html-pdf to save a quote made with sails , .ejs , and angular into a pdf to send it to the customer. An .ejs file (view folder) and its assign .js controller (assets folder) allows the user to create the quote, select the customer, add products, and finally calculate the total of the quote. All the data are bound with angular. I use bootstrap.min.css and importer.css files for my CSS and mostly the Bootstrap grid for my display. When to quote is ready, I have a 'save as PDF'

mongodb update push array

人走茶凉 提交于 2019-12-24 21:09:36
问题 I have the following schema. I am using node.js with mongodb attributes: { type: { type: 'string' }, title: { type:'string' }, description: { type:'string' }, is_active: { type:'boolean',defaultsTo:true }, createdBy: { type:'json' }, attachments:{ type:'array' } } arr = [{ 'id':attResult.id, 'subtype':type, 'title' : attResult.title, 'body' : attResult.body, 'filetype' : attResult.filetype }]; I am trying to push a attachments into the 'attachments' array that will be unique to the document.

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

How to store array of ObjectID's in Mongo with Sails?

你说的曾经没有我的故事 提交于 2019-12-24 14:46:28
问题 After my initial question: Handling relationships in Mongo and Sails? I managed to use this approach, however I now need to resolve this the way I originally thought. For example, I have my Photo and Category models & collections, but now my category also contains addresses and business details. In my Photo model I have the following: attributes: { caption : { type : 'string' }, fid : { type : 'string' }, user : { model : 'user' }, categories : { model : 'category', type : 'array'} } In my