My School model has a name, address, etc. and an owner which is a User object.
School.js
module.exports = {
attributes: {
name: {
type: 'string',
required: true
},
address: {
type: 'string'
},
owner: {
model: 'user'
},
...
When creating a new school I do the following:
create: function(req, res, next) {
School.create(req.params.all(), function schoolCreated (err, school) {
but what is the easiest way to add the owner (which after login is found in the session at req.session.user)?
I get that I can do
create: function(req, res, next) {
School.create({'name': req.params.name, 'address': req.params.address, 'owner': req.session.user}, function schoolCreated (err, school) {...
but there must be an easier way. Any examples would help tremendously! Thank you so much!