'use strict';


exports.save_by_key = async function () {
    await this.bindDefault();
    //  先把项目进行保存
    this.body =  await this.mongo("Project",this.request.body).saveByKey();
    //  在tag里面创建默认的标签
    await this.mongo("Tag",{title:"默认标识",projects:this.body._id,is_default:1}).saveByKey();

	return
}
exports.save_by_key.__method__ = 'POST';

exports.query = async function () {
    await this.bindDefault();
    this.body = await this.mongo("Project").query();
	return
}
exports.query.__method__ = 'GET';

exports.delete = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Project").delete(this.request.query._id);
    return
}
exports.delete.__method__ = "GET";

exports.update_by_id = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Project").update(this.request.query._id,this.request.query);
    return
}
exports.update_by_id.__method__ = "PUT"

exports.resetDefaultProject = async function(){
    await this.bindDefault();
    this.body = await this.mongo("Project").setDefault(this.request.query._id);
    return
}
exports.resetDefaultProject.__method__ = "PUT"