本文共 2471 字,大约阅读时间需要 8 分钟。
- exports.insert = function(modelname, data) {
- var model = require('./models/' + modelname);
- model.create(data, function(err, doc) {
- if (err)
- return next(err);
- });
- };
-
-
- exports.remove = function(modelname, conditions, callback) {
- var model = require('./models/' + modelname);
- model.remove(conditions, function(err, doc) {
- if (err)
- return next(err);
- });
- };
-
-
-
-
-
-
-
-
-
-
-
-
- exports.update = function(modelname, conditions, doc, options, callback) {
- var model = require('./models/' + modelname);
- var options = {};
- model.update(conditions, doc, options, function(err, doc) {
- console.log(doc + "," + err);
- });
- };
-
-
-
-
- exports.find = function(modelname, data) {
- var model = require('./models/' + modelname);
- model.find(data, function(err, doc) {
- if (err)
- return next(err);
- });
- };
-
-
-
-
-
-
-
-
-
-
-
- exports.find = function find (modelname,conditions, fields, options, callback) {
- var model = require('./models/' + modelname);
- model.find(conditions, fields, options,function (){
-
- });
- };
-
-
-
-
- exports.findOne = function(modelname, fields, options, callback){
- var model = require('./models/' + modelname);
- model.findOne(fields, function() {
-
- });
- };
-
-
-
-
- exports.findOneAndUpdate = function(modelname, conditions, update, options, callback){
- var model = require('./models/' + modelname);
- model.findOneAndUpdate(conditions, update, options, function() {
-
- });
- };
转载地址:http://fitta.baihongyu.com/