Task #28 - 'Magic trick' - correct lengthy code

This commit is contained in:
QiTao 2020-02-08 05:20:15 -06:00
parent 68b20a5cf4
commit 5211694adb

View File

@ -0,0 +1,29 @@
const Controller = require('libflitter/controller/Controller')
/*
* Export Controller
* -------------------------------------------------------------
* Put some description here!
*/
class Export extends Controller {
static get services() {
return [...super.services, 'models']
}
/*
* Serve the main page.
*/
async json_export(req, res){
const Page = this.models.get('api:Page')
const user = req.user
const pages = await Page.find({OrgUserId:user._id})
const ExportData = {}
for (const page of pages ) {
const PageData = {...page}
ExportData[page.Name] = PageData
}
return res.api(ExportData)
}
}
module.exports = exports = Export