/**
 * Created by Mai on 2017/6/13.
 */

let baseModel = require('./base_model');
import {default as projCounterSchema, collectionName as collectionName} from "./schemas/proj_counter";

class projCounter extends baseModel {
    constructor() {
        super(projCounterSchema);
        this.collectionName = collectionName;
    }

    getData (projectID, callback) {
        this.model.findOne({"projectID": projectID}, '-_id', function (err, result) {
            if (!err) {
                callback(0, collectionName, result);
            } else {
                callback(1, '查询数据失败。', null);
            }
        });
    };

    save (user_id, data, callback) {
        this.model.update({"projectID": data.projectID}, data, callback);
    }
};

module.exports = new projCounter();
