I have a need to generate auto-incrementing numbers. I added onPreSave business logic script which worked fine until today (well, I found it today). Here's the script:
Unfortunately, Kinvey changed what is returned in `doc` argument to the callback function. Before it document with updated value, not some sort of following object:
{
entity: {...},
updatedExisting: true
}
Is this documented change and it will stay like this in the future?
Serge Koval
function onPreSave(request, response, modules){
var collectionAccess = modules.collectionAccess,
body = request.body;
if (typeof body.uniqueId !== 'number') {
collectionAccess.collection('Counters').findAndModify({name: 'estimate'}, [], {$inc: {'counter': 1}},
function(err, doc) {
body.uniqueId = doc ? doc.counter : 0;
response.continue();
});
} else {
response.continue();
}
}
Unfortunately, Kinvey changed what is returned in `doc` argument to the callback function. Before it document with updated value, not some sort of following object:
{
entity: {...},
updatedExisting: true
}
Is this documented change and it will stay like this in the future?