/**
 * 压测模块1
 *
 * @author CaiAoLin
 * @date 2017/8/3
 * @version
 */
import BaseModel from "../../modules/common/base/base_model";
import Test3Schema from "./schemas/test3";

class Test3Model extends BaseModel {

    /**
     * 构造函数
     *
     * @return {void}
     */
    constructor() {
        let parent = super();
        parent.model = Test3Schema;
        parent.init();
    }

    /**
     * 初始化数据
     *
     * @return {Promise}
     */
    async test() {
        let name = 'test3';
        // let update = {$inc: {value: 1}};
        let update = {value: 1};
        let condition = {name: name};
        let options = {new: true};

        // 先查找更新
        // let idData = await this.db.findAndModify(condition, update, options);
        let idData = await this.db.incr(condition, update);

        // return idData !== null;
        return idData !== null && idData.ok === 1;
    }
}

export default Test3Model;

