I have a common method for updating document of any collection in MongoDB?
The following code is in file name Deleter.js
module.exports
I found it better to avoid global and exception handing-
var mongoose = require("mongoose");
var _ = require("underscore");
var model;
if (_.indexOf(mongoose.modelNames(), "Find")) {
var CategorySchema = new mongoose.Schema({
name: String,
subCategory: [
{
categoryCode: String,
subCategoryName: String,
code: String
}
]
}, {
collection: 'category'
});
model = mongoose.model('Category', CategorySchema);
}
else {
model = mongoose.model('Category');
}
module.exports = model;