Socket
Socket
Sign inDemoInstall

@mqict/adonis-controller

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @mqict/adonis-controller

MQ-Controller is a set of base Controller for MQ's Team server. MQ-Controller runs on **Adonisjs 4**,


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Welcome to MQ-Controller!

MQ-Controller is a set of base Controller for MQ's Team server. MQ-Controller runs on Adonisjs 4,

Install

npm install @mqict/adonis-controller

in Controller file: use use('@mqict/adonis-controller') as BaseController.

	const Controller =  use('@mqict/adonis-controller')
    class  ApiController  extends  Controller {
    	.....
    }

in start/routes.js:

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

{{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:

{
    "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:

{{host}}/api/students/getschema (GET method)

output

{
    "_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

FAQs

Last updated on 27 Dec 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc