In an "afterRemote"-Hook i want to find a specific model and change an attribute:
Team.afterRemote('prototype.__create__messages', function(ctx, message, next) {
var Message = Team.app.models.message;
// Promises.all not required, just for debugging (i removed other code)
const promises = Promise.all( [
Message.findById(message.id),
] )
promises.then( function(result) {
console.log("FOUND Message ", result);
// here i'd like to change an attribute and save the model back to database
console.log(typeof result.save); // will print undefined
});
How could i manipulate the found entity and save it? Save()-Method is not present. All in all findById delivers a plain JSON-object, not a real PersistedModel-Instance.
The Model was defined as:
{
"name": "message",
"base": "PersistedModel",
"strict": false,
"idInjection": false,
"options": {
"validateUpsert": true
},
Database is a mongoDB.