我正在尝试构建注释模型包含:Reply和CommentThread.CommentThread包含Reply,而Reply可以自行递归.
/models/comment.js:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var replySchema = new Schema({
username: String,
timestamp: { type: Date, default: Date.now },
body: String,
replies: [replySchema]
}, {_id: true});
var commentThreadSchema = new Schema({
title: String,
replies: [replySchema]
});
var Reply = mongoose.model('Reply', replySchema);
var CommentThread = mongoose.model('CommentThread', commentThreadSchema);
module.exports = {
Reply: Reply,
CommentThread: CommentThread
};
Run Code Online (Sandbox Code Playgroud)
我的错误消息是:架构阵列路径'回复'的值无效.不能replySchema将自己用作值类型?还是其他一些原因?
c:\Users\jacki_000\projects\invictusblog\node_modules\mongoose\lib\schema.js:297
throw new TypeError('Invalid value for schema Array path `'+ prefix + ke
^
TypeError: Invalid value for schema Array …Run Code Online (Sandbox Code Playgroud) 我知道如何使用“选择顶部”来编写分页查询,但是我不知道如何使用行号来编写它。谁能告诉我?谢谢!