Skip to content

Commit

Permalink
my
Browse files Browse the repository at this point in the history
  • Loading branch information
hesizhe committed Dec 8, 2018
1 parent 25dffa8 commit 40177ae
Show file tree
Hide file tree
Showing 14 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions Schema/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const ArticleSchema = new Schema({
type: ObjectId,
ref: "users"
},
commentNum: Number,
tips: String
},{
versionKey: false,
Expand Down
6 changes: 3 additions & 3 deletions control/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports.addSubmit = async (ctx) => {

// 添加文章作者
data.author = ctx.session.uId;
data.commentNum = 0;

await new Promise((resolve, reject) => {
const _article= new Article(data);
Expand All @@ -48,6 +49,7 @@ exports.addSubmit = async (ctx) => {
}
})
.catch(err => {
console.log(err);
ctx.body = {
msg: "请重新发送",
status: 0
Expand All @@ -60,7 +62,7 @@ exports.getList = async (ctx) => {
// 查询文章(作者 头像)
let page = ctx.params.id || 1;

const maxNum = await Article.estimatedDocumentCount((err, num) => err? console.log(err) : num)
const maxNum = await Article.estimatedDocumentCount((err, num) => err? console.log(err) : num)
const artList = await Article
.find()
.sort("-created")
Expand All @@ -72,7 +74,6 @@ exports.getList = async (ctx) => {
})
.then(data => data)
.catch(err => console.log(err));
console.log(artList);

await ctx.render('index', {
title: "博客实战主页",
Expand All @@ -93,7 +94,6 @@ exports.details = async (ctx) => {
.findById(_id)
.populate("author", "username")
.then(data => data);
console.log(article);

// 查询当前文章所关联的评论数据
const comment = await Comment
Expand Down
7 changes: 5 additions & 2 deletions control/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ exports.save = async (ctx) => {
msg: "评论成功"
}
// 更新评论 count


Article
.update({_id: data.article},{$inc: {commentNum: 1}}, (err) => {
if(err)return console.log(err);
})
})
.catch(err => {
console.log(err);
message = {
status: 0,
msg: "用户未登录"
Expand Down
2 changes: 1 addition & 1 deletion database/db/WiredTiger.turtle
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ WiredTiger 2.9.2: (December 23, 2016)
WiredTiger version
major=2,minor=9,patch=2
file:WiredTiger.wt
access_pattern_hint=none,allocation_size=4KB,app_metadata=,block_allocation=best,block_compressor=,cache_resident=false,checkpoint=(WiredTigerCheckpoint.49=(addr="018881e453e543e08981e4883259218a81e4dbf53744808080e2efc0e22fc0",order=49,time=1544209265,size=24576,write_gen=97)),checkpoint_lsn=(2,25344),checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1)
access_pattern_hint=none,allocation_size=4KB,app_metadata=,block_allocation=best,block_compressor=,cache_resident=false,checkpoint=(WiredTigerCheckpoint.71=(addr="018081e4a49046f88181e4bbb242178281e4c6518509808080e2efc0e22fc0",order=71,time=1544280613,size=24576,write_gen=138)),checkpoint_lsn=(6,9728),checksum=uncompressed,collator=,columns=,dictionary=0,encryption=(keyid=,name=),format=btree,huffman_key=,huffman_value=,id=0,ignore_in_memory_cache_size=false,internal_item_max=0,internal_key_max=0,internal_key_truncate=true,internal_page_max=4KB,key_format=S,key_gap=10,leaf_item_max=0,leaf_key_max=0,leaf_page_max=32KB,leaf_value_max=0,log=(enabled=true),memory_page_max=5MB,os_cache_dirty_max=0,os_cache_max=0,prefix_compression=false,prefix_compression_min=4,split_deepen_min_child=0,split_deepen_per_child=0,split_pct=90,value_format=S,version=(major=1,minor=1)
Binary file modified database/db/WiredTiger.wt
Binary file not shown.
Binary file modified database/db/blogproject/collection-0-4090759420862470414.wt
Binary file not shown.
Binary file modified database/db/blogproject/index-1-4090759420862470414.wt
Binary file not shown.
Binary file modified database/db/collection-0-7501986788463172094.wt
Binary file not shown.
Binary file modified database/db/collection-7-7501986788463172094.wt
Binary file not shown.
Binary file removed database/db/diagnostic.data/metrics.interim
Binary file not shown.
Binary file modified database/db/index-1-7501986788463172094.wt
Binary file not shown.
Binary file modified database/db/index-8-7501986788463172094.wt
Binary file not shown.
Binary file removed database/db/journal/WiredTigerLog.0000000002
Binary file not shown.
Binary file modified database/db/sizeStorer.wt
Binary file not shown.

0 comments on commit 40177ae

Please sign in to comment.