{"size": 819, "ext": "js", "max_stars_repo_path": "template/src/controllers/test.js", "max_stars_repo_name": "lwyj123/koa-backend-template", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "template/src/controllers/test.js", "max_issues_repo_name": "lwyj123/koa-backend-template", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "template/src/controllers/test.js", "max_forks_repo_name": "lwyj123/koa-backend-template", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.0, "max_line_length": 61, "alphanum_fraction": 0.5811965812}

// const path = require('path')
const BaseController = require('./prototype/BaseController')
const ArticleModal = require('../models/article')
const pagination = require('../helpers/page')

class Test extends BaseController {
  async GetArticleList (ctx) {
    const query = ctx.query
    const searchQuery = {}
    // if (false) {
    //   searchQuery.$and = []
    // }
    // if (false) {
    //   searchQuery.$or = []
    // }
    const list = await ArticleModal
      .find(searchQuery)
      .sort({ updated_at: -1 })

    const data = pagination.getCurrentPageDataWithPagination(
      list.map(item => item.toObject()),
      query.offset + 1,
      query.limit
    )
    ctx.body = {
      ...data
    }
  }

  async test (ctx) {
    ctx.body = {
      'test': 'wori'
    }
  }
}

module.exports = new Test()
