I've setup a business logic script to change a value on my users, if a new object is saved in a specific data-collection.
Problem:
The user-table is set to private and actually i don't want to change that. So my question is, how to make the following "call" with user-data to "authenticate" the change of the value.
function onPostSave(request, response, modules){
//
// Variables
//
var collectionAccess = modules.collectionAccess;
var pointsToAdd = request.body.points;
var _userID = request.body.user_id;
// Fetch the User
collectionAccess.collection('user').findOne({"_id": modules.collectionAccess.objectID(_userID)}, function (err, docs) {
Nico Barelmann
following scenario:
I've setup a business logic script to change a value on my users, if a new object is saved in a specific data-collection.
Problem:
The user-table is set to private and actually i don't want to change that. So my question is, how to make the following "call" with user-data to "authenticate" the change of the value.
function onPostSave(request, response, modules){
//
// Variables
//
var collectionAccess = modules.collectionAccess;
var pointsToAdd = request.body.points;
var _userID = request.body.user_id;
// Fetch the User
collectionAccess.collection('user').findOne({"_id": modules.collectionAccess.objectID(_userID)}, function (err, docs) {
// Calculate new Points Value
var newPoints = (docs.points += pointsToAdd);
collectionAccess.collection('user').update({"_id" : modules.collectionAccess.objectID(eventID)}, {$set:{"promised_count":newCount}}, function(err, docs) {
response.complete(200);
});
});
}
Any hint or answer would be great. :smile:
Best, Nico