общей/модель/event.jsonКак получить параметры запроса в модели в Loopback
{
"name": "Event",
"mongodb": {
"collection": "event"
},
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"http": {
"path": "organizer/:organizer_id/events"
},
"properties": {},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
общий/модель/event.js
module.exports = function (Event) {
Event.disableRemoteMethod('upsert', true);
Event.disableRemoteMethod('exists', true);
Event.disableRemoteMethod('findOne', true);
Event.disableRemoteMethod('count', true);
Event.disableRemoteMethod('prototype.updateAttributes', true);
// Before get records put orgnaizerId in query
Event.observe('access', function (ctx, next) {
var organizer_id = '';
if (ctx.query.where) {
ctx.query.where.organizerId = organizer_id;
} else {
ctx.query.where = {organizerId: organizer_id};
}
console.log(ctx.query);
next();
});
}
в Access крючках Операции в event.js Я хочу чтобы получить organizer_id параметр из URL определяется в event.json как
"http": {
"path": "organizer/:organizer_id/events"
}
в примере URL выглядеть example.com/organizer/54c88f62e4b0b0fca2d0f827/events/
Как это сделать?