Jump to 0.3.1
This commit is contained in:
13
lib/temp.js
13
lib/temp.js
@@ -4,6 +4,7 @@ var mongoose = require('mongoose');
|
||||
|
||||
//core
|
||||
var config = require("../config.js");
|
||||
var logger = require("./logger.js");
|
||||
|
||||
// create a temp model
|
||||
var model = mongoose.model('temp', {
|
||||
@@ -33,13 +34,13 @@ function findTemp(id, callback) {
|
||||
id: id
|
||||
}, function (err, temp) {
|
||||
if (err) {
|
||||
console.log('find temp failed: ' + err);
|
||||
logger.error('find temp failed: ' + err);
|
||||
callback(err, null);
|
||||
}
|
||||
if (!err && temp) {
|
||||
callback(null, temp);
|
||||
} else {
|
||||
console.log('find temp failed: ' + err);
|
||||
logger.error('find temp failed: ' + err);
|
||||
callback(err, null);
|
||||
};
|
||||
});
|
||||
@@ -53,10 +54,10 @@ function newTemp(id, data, callback) {
|
||||
});
|
||||
temp.save(function (err) {
|
||||
if (err) {
|
||||
console.log('new temp failed: ' + err);
|
||||
logger.error('new temp failed: ' + err);
|
||||
callback(err, null);
|
||||
} else {
|
||||
console.log("new temp success: " + temp.id);
|
||||
logger.info("new temp success: " + temp.id);
|
||||
callback(null, temp);
|
||||
};
|
||||
});
|
||||
@@ -67,14 +68,14 @@ function removeTemp(id, callback) {
|
||||
if(!err && temp) {
|
||||
temp.remove(function(err) {
|
||||
if(err) {
|
||||
console.log('remove temp failed: ' + err);
|
||||
logger.error('remove temp failed: ' + err);
|
||||
callback(err, null);
|
||||
} else {
|
||||
callback(null, null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.log('remove temp failed: ' + err);
|
||||
logger.error('remove temp failed: ' + err);
|
||||
callback(err, null);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user