{"size": 612, "ext": "js", "max_stars_repo_path": "dbControl/commentAction.js", "max_stars_repo_name": "Zivcheung/personal-blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "dbControl/commentAction.js", "max_issues_repo_name": "Zivcheung/personal-blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "dbControl/commentAction.js", "max_forks_repo_name": "Zivcheung/personal-blog", "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": 19.125, "max_line_length": 45, "alphanum_fraction": 0.5098039216}

const comModel = require("../model/comment");

async function addComment(ctx) {
    const post = ctx.request.body;
    const session = ctx.session;

    try {
        const fb = comModel.create({
            content: post.content,
            article: post.article,
            author: session.uid,
        });

        ctx.body = {
            status:1,
            msg: "comment upload succeed"
        }

    } catch (err) {
        console.log("commentAction: "+ err);
        ctx.body = {
            status: 0,
            msg: "comment upload fails"
        }
    }
}

exports.addComment = addComment;


