I have been facing a issue which needs the array like model. my current model is
module.exports = {
attributes: {
foodname:{
type: 'string',
unique: true,
required: true,
},
foodreview:'string',
foodlocation:'string',
foodcategory:'string',
foodupvote:'integer',
fooddownvote:'integer',
owner: {
model: 'user'
},
Comments: {
collection: 'comments',
via: 'comment'
}
}
};
Now i want to add vote array in this, so that i can know how much upvote and downvote a food got. user should vote only once for a food. So what i need is something like this
module.exports = {
attributes: {
foodname:{
type: 'string',
unique: true,
required: true,
},
foodreview:'string',
foodlocation:'string',
foodcategory:'string',
foodupvote:'integer',
fooddownvote:'integer',
owner: {
model: 'user'
},
Comments: {
collection: 'comments',
via: 'comment'
},
vote:{}
}
};
What is the best way to achieve this?