Commit 4b5bd228 authored by 陈家荣's avatar 陈家荣

更新了文章评论

parent 9f314d69
'use strict'; 'use strict';
var mongoose = require('mongoose'); var mongoose = require('mongoose');
var ForumComment = mongoose.model('ForumComment'); var ForumComment = mongoose.model('ForumComment');
...@@ -30,12 +32,13 @@ exports.getCommentById=function(cid,callback){ ...@@ -30,12 +32,13 @@ exports.getCommentById=function(cid,callback){
}; };
//根据ID更新评论 //根据ID更新评论
exports.updateCommentById=function(cid,entity,callback){ exports.updateCommentById=function(cid,status,callback){
ForumComment.update({ _id: cid}, entity,null,function(err,result){ ForumComment.update({ _id: cid}, {"status" : status},null,function(err,result){
if (err) { if (err) {
console.error(err); console.error(err);
callback(err,null); callback(err,null);
} else { } else {
console.log(result);
callback(null,null); callback(null,null);
} }
}); });
...@@ -74,7 +77,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) { ...@@ -74,7 +77,7 @@ exports.getAllComment= function(conditions,pageNo,pageSize,callback) {
}else{ }else{
var skip = (pageNo - 1) * pageSize; var skip = (pageNo - 1) * pageSize;
var limit = count - skip > pageSize ? pageSize : (count - skip); var limit = count - skip > pageSize ? pageSize : (count - skip);
console.log("count:" + count);
ForumComment.find(conditions).populate('from').populate('to').limit(limit).skip(skip).sort('-created').exec(function(err, docs) { ForumComment.find(conditions).populate('from').populate('to').limit(limit).skip(skip).sort('-created').exec(function(err, docs) {
if (err) { if (err) {
console.error(err); console.error(err);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment