|
@@ -15,11 +15,26 @@ counterSchema.statics.findAndModify = function (query, sort, doc, options, callb
|
|
|
};
|
|
|
var counterModel = projectdb.model("counters", counterSchema);
|
|
|
|
|
|
-const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
|
|
|
- REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'
|
|
|
+// All counter Must predefine in DB
|
|
|
+const COUNTER_MODULE_NAME = {
|
|
|
+ project: 'projects',
|
|
|
+ user: 'users',
|
|
|
+ bills: 'bills',
|
|
|
+ ration: 'rations',
|
|
|
+ report: 'rptTemplates',
|
|
|
+ fee: 'fees',
|
|
|
+ template_bills: 'temp_bills'
|
|
|
+}
|
|
|
+/*const PROJECT_COUNTER = 'projects', USER_COUNTER = 'users', BILL_COUNTER = 'bills', RATION_COUNTER = 'rations',
|
|
|
+ REPORT_COUNTER = 'rptTemplates', FEE_COUNTER = 'fees'*/
|
|
|
|
|
|
var counterDAO = function(){};
|
|
|
|
|
|
+/*
|
|
|
+ * callback = function (err, result) {
|
|
|
+ * result.value.sequence_value ΪÐ޸ĺóµÄid
|
|
|
+ * }
|
|
|
+ */
|
|
|
counterDAO.prototype.getIDAfterCount = function(moduleName, stepCount, callback) {
|
|
|
var sc = stepCount;
|
|
|
if (isNaN(stepCount) || (stepCount < 0)) {
|
|
@@ -46,4 +61,7 @@ counterDAO.prototype.getCurrentID = function(moduleName, callback) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-module.exports = new counterDAO();
|
|
|
+module.exports = {
|
|
|
+ counterDAO: new counterDAO(),
|
|
|
+ moduleName: COUNTER_MODULE_NAME
|
|
|
+};
|