/**
 * 配合比标准库业务模型
 *
 * @author CaiAoLin
 * @date 2017/7/10
 * @version
 */
const mongoose = require("mongoose");
const BaseModel = require("../base/base_model");

class STDMixRatioModel extends BaseModel {

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

    /**
     * 根据编码获取对应的组成物信息
     *
     * @param {String} code
     * @return {Promise}
     */
    async getDataByCode(code) {
        let result = [];
        code = code.trim();
        try {
            if (code === '') {
                throw '编码为空';
            }
            result = await this.findDataByCondition({connect_code: code}, null, false);
        } catch (error) {
            console.log('std_mix_ratio_model:' + error);
            result = [];
        }

        return result;
    }

}

export default STDMixRatioModel;
