adonis-mqcontroller
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "adonis-mqcontroller", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"private": false, | ||
"main": "./BaseController.js", | ||
"dependencies": { | ||
"adonis-mqmodel": "^1.0.4" | ||
} | ||
"adonis-mqmodel": "^1.0.4", | ||
"pluralize": "*" | ||
} | ||
} |
147
README.md
@@ -15,4 +15,151 @@ # Welcome to MQ-Controller! | ||
``` | ||
in start/routes.js: | ||
```javascript | ||
const Route = use('Route') | ||
const { ioc } = use('@adonisjs/fold') //<---- add | ||
const pluralize = use('pluralize') //<---- add | ||
.... | ||
Route.post('/:controller/getdata', ({view ,request, response,params}) => { | ||
const controller = pluralize.singular(params.controller) | ||
const url = `App/Controllers/Http/Api/${controller}Controller.getData` | ||
const controllerInstance = ioc.makeFunc(url) | ||
return controllerInstance.method.apply(controllerInstance.instance,[{view,request,response}]) | ||
}) | ||
Route.post('/:controller/getschema', ({view ,request, response,params}) => { | ||
const controller = pluralize.singular(params.controller) | ||
const url = `App/Controllers/Http/Api/${controller}Controller.getSchema` | ||
const controllerInstance = ioc.makeFunc(url) | ||
return controllerInstance.method.apply(controllerInstance.instance,[{view,request,response}]) | ||
}) | ||
``` | ||
# Using | ||
```javascript | ||
{{host}}/api/students/getdata (POST method) | ||
BODY: | ||
{ | ||
"fields": { | ||
"firstname": 1, | ||
"lastname": 1, | ||
"basicClass": { | ||
"_id": 1, | ||
"name": 1, | ||
"students": { | ||
"_id": 1, | ||
"firstname": 1, | ||
"lastname": 1, | ||
"$limit": 1 | ||
}, | ||
"occupation": { | ||
"_id": 1, | ||
"name": 1, | ||
"institute": { | ||
"_id": 1, | ||
"name": 1 | ||
} | ||
} | ||
} | ||
}, | ||
"conditions": { | ||
"firstname": "đức" | ||
}, | ||
"page": 0, | ||
"pageSize": 20, | ||
"sorted": [ | ||
{"id": "firstname", "desc": true} | ||
] | ||
} | ||
``` | ||
output: | ||
```javascript | ||
{ | ||
"total": 2, | ||
"perPage": 20, | ||
"lastPage": 1, | ||
"page": 1, | ||
"data": [ | ||
{ | ||
"_id": "5b8f2e822d904647341c5838", | ||
"firstname": "Đỗ Đức", | ||
"lastname": "Thu", | ||
"basicClass": { | ||
"_id": "5b8e61a0269e861e1c150b86", | ||
"name": "co so nghanh 2 k9", | ||
"students": [ | ||
{ | ||
"_id": "5b8e4f172d904647341c582a", | ||
"firstname": "Đinh Đức", | ||
"lastname": "Thuận" | ||
} | ||
], | ||
"occupation": { | ||
"_id": "5b7675b712e8540b92191b68", | ||
"name": "Nghề thiết kế đồ họa", | ||
"institute": { | ||
"_id": "5b767592a8cc5c0b8a643623", | ||
"name": "Khoa Công Nghệ Thông Tin" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"_id": "5b8e4f172d904647341c582a", | ||
"firstname": "Đinh Đức", | ||
"lastname": "Thuận", | ||
"basicClass": { | ||
"_id": "5b8e47650ae80929d4da6ffc", | ||
"name": "Cơ sở nghành K9", | ||
"students": [ | ||
{ | ||
"_id": "5b8e4f172d904647341c5823", | ||
"firstname": "Nguyễn Chí", | ||
"lastname": "Tài" | ||
} | ||
], | ||
"occupation": { | ||
"institute": {} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
``` | ||
###get schema: | ||
```javascript | ||
{{host}}/api/students/getschema (GET method) | ||
``` | ||
output | ||
```javascript | ||
{ | ||
"_id": "objectid", | ||
"code": "string", | ||
"firstname": "string", | ||
"lastname": "string", | ||
"birthday": "string", | ||
"identified_number": "string", | ||
"gender": "string", | ||
"place_of_birth": "string", | ||
"hometown": "string", | ||
"address": "string", | ||
"phone": "string", | ||
"area": "string", | ||
"ethnic": "string", | ||
"relationships": "array", | ||
"courseId": "objectid", | ||
"status": "number", | ||
"created_at": "moment", | ||
"updated_at": "moment", | ||
"basicClassId": "objectid", | ||
"specifiedClassId": "object", | ||
"fees": "array", | ||
"course": "function", | ||
"basicClass": "function", | ||
"specifiedClass": "function" | ||
} | ||
``` | ||
NgocHip |
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
5498
165
2
2
+ Addedpluralize@*
+ Addedpluralize@8.0.0(transitive)