You can try using the collectionAccess
module available from within your BL script. The docs for it can be found here.
For example, to save a new object into the notifications
collection, you would:
function onPreSave(req, res, modules) {
var db = modules.collectionAccess,
objectToSave = { foo: "bar" };
db.collection('notifications').save(objectToSave, function(err, objectThatWasSaved) {
if (err) {
// do some error reporting here
} else {
// Hooray! It worked
// !! Make sure to call res.complete or res.continue
// !! to tell Kinvey you are done processing. Check
// !! the docs I linked to for the details
res.continue();
}
});
}
Full disclosure: I'm a developer at Kinvey