So, I'm learning the strongloop API, and extending my API: https://docs.strongloop.com/display/public/LB/Extend+your+API
I modified the getName
example:
Node.setData = function(response, cb) {
console.log(response)
// cb(null, response);
};
Node.remoteMethod(
'setData',
{
http: {path: '/:id/setData', verb: 'get'},
accepts: [
{arg:'data', type:'string'},
{arg:'id', type:'string', required: true}
],
returns: {arg: 'setData', type: 'string'},
description: [ 'set some Data ']
}
);
Which works as expected (at least it shows in the list):
Things I'd like to have clarified and can't find anywhere in the docs:
- How to tell my database connector (MongoDB) to put data in, because strongloop comes with a lot of default remoteMethods, but I can't find anywhere how they are defined. And getting data works semi-automagically, but setting seems really obscure in the documentations.
- I'm assuming I should not talk to the database-connector, but through a certain loopback interface;
- How/Where to use methods like
Node.updateAttribute('data', 'test')
, because inside theNode.setData
function I get undefined method. I see it is part ofpersistedModel
but, where I use this is a mystery to me. - Why
cb()
is undefined, while in the example it should work
I've tried it with verb post
as well, but this should not matter, i want to be able to write some data to the db when I get a request for example.
I'm probably not the first that finds the learning curve for Strongloop pretty steep. Anyone know of any tutorials that give me a better understanding? I've been through the core concepts and getting started, but I have the feeling that I not even got started at all.