I have two collections; user and address. Address collection has association with user collection.
module.exports = {
attributes: {
email: {
type: 'email',
required: true,
unique: true
},
cart: {
collection: 'cart',
via: 'user'
},
isAdmin : {
type : 'boolean',
defaultsTo : false
},
}
module.exports = {
attributes: {
user: {
model: 'user',
required: true
},
address: {
type: 'string',
},
addressAdditional: {
type: 'string',
},
city: {
type: 'string',
},
state: {
type: 'json',
},
zip: {
type: 'string',
},
}
I have the userId and address info passed from the UI and I would like to update the address collection. I tried the following snippet but it does not seem like the data is getting updated.
var address = {
address: "123",
city: "Test City",
state: "NY",
zip: "12345"
};
User.findOne({user:userId}).then(function(model){
Address.update({id:model.id}, address)});
What am I doing wrong? Thanks