/**
 * Created by Zhong on 2017/12/22.
 */

let rationRepositoryModel = require('../../ration_repository/models/repository_map').Model;

class CompleViewModel {
    async getRationLib(rationRepId, callback){
        try{
            let rationLib = await rationRepositoryModel.find({ID: rationRepId, $or: [{deleted: null}, {deleted: false}]});
            callback(0, rationLib);
        }
        catch(err) {
            callback(err, null);
        }
    }

    async getRationLibs(compilationId, ids, callback){
        try{
            let rationLibs = await rationRepositoryModel.find({compilationId: compilationId, ID: {$in: ids}, $or: [{deleted: null}, {deleted: false}]});
            callback(0, rationLibs);
        }
        catch(err) {
            callback(err, null);
        }
    }
}

module.exports = CompleViewModel;