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

let mongoose = require("mongoose");
let baseModel = require('./base_model');

let collectionName = 'projCounter';
class projCounter extends baseModel {
    constructor() {
        super(mongoose.model(collectionName));
        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();
