我正在使用 nodejs、express、mongo 和 coffeescript,我有一篇带有评论的简单博客文章,我想添加在任何给定时间删除特定评论的可能性。架构如下所示:
Schema = mongoose.Schema
ArticleSchema = new Schema
title:
type: String
trim: true
required: true
body:
type: String
required: true
createdAt:
type: Date
default: Date.now
comments: [
body:
type: String
default : ''
user:
type: Schema.ObjectId
ref: 'User'
required: true
createdAt:
type: Date
default: Date.now
]
文章的路线映射如下:
articles = require '../app/controllers/articles'
app.get '/', articles.index
app.get '/articles', articles.manage
app.get '/articles/new', auth.requiresLogin, articles.new
app.get '/articles/:articleId', articles.show
app.get '/articles/:articleId/edit', auth.requiresLogin, articles.edit
app.param 'articleId', articles.article
但是我该如何做这样的事情才能删除评论呢?
app.get '/articles/:articleId/comment/:commentId/delete', auth.requiresLogin, articles.edit