Closed tomBeach closed 9 years ago
Closing this to continue in the other thread.
This might be helpful: http://stackoverflow.com/questions/25880539/join-across-multiple-junction-tables-with-sequelize
It looks like it includes the related data in the output of the findAll
.
Here is an example of why this is so frustrating; One of the few routes I have been able to get working is the one below (uncommented version), yet even when the route is successful it does not display console.log statements. (I even tried commenting out everything except the console.logs and still saw nothing!) I know the route itself works because when commenting the whole thing it fails (duh...).
More importantly, I can't figure out how to deal with the second selection criterion in the route ("group"). I am looking for stocks that are matched to the owner (user) via the ownership join table. Each record in that table also has a "group" column (e.g. "portfolio", "watchList", etc.), a string that should be searchable. When I add the group parameter to the route it fails. I can't tell if it's being passed in since nothing will console.log from this route. Or should group be passed in the params object? If so, how does it get into params from the ajax call (below route code). This process would be so much more understandable if these parameters could be passed as basic arguments as they are in so many other programming situations...
Beyond that, I do not understand where user.getStocks comes from. I don't see it defined anywhere in the code. I assume it's a "built-in" function, but I can't find a reference anywhere that explains the syntax of built-in functions. (Can it take arguments? Would it be "deleteStocks" or "updateStocks" for delete or patch requests?) Since we are actually dealing with the join table (which never appears in this code but is the basis for everything going on here) how does it know to look in the group column of the join table if the join table is never mentioned?
So many questions...
successful route
ajax call