V
V
Vlad Timofeev2015-01-09 23:00:59
MongoDB
Vlad Timofeev, 2015-01-09 23:00:59

How to make a post-comment system in node.js?

Good day.
As far as I understand, the scheme needs to be done like this? :

var postSchema = mongoose.Schema({
    tags: [String],
    text: String,
    author: {
        name: String,
        url: String
    },
    addtime: String,
    answers: [
        answer={
            author: {
                name: String,
                url: String
            },
            text: String,
            comments: [
                comment={
                    author: {
                        name: String,
                        url: String
                    },
                    text: String
                }
            ],
        }
    ]
});

It seems to me that this is not so :(
Please tell me how to organize this and then give it in response ..
Or is there already a module that will do everything for the developer? :DD I
use express.js & jade
I will be grateful)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Timofeev, 2015-01-09
@PyTiMa

Maybe so?:

var postSchema = mongoose.Schema({
    tags: [String],
    text: String,
    author: {
        name: String,
        url: String
    },
    addtime: String,
    answers: [
        comments=[],
        
    ]
});

And then push the answer object in answers answers and in answers[comments] push the comment object?

E
Egor, 2015-01-09
@ByKraB

What answer do you want to hear to this question? Ready code?
You can write code that will work with any database schema. Nothing much depends on the scheme itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question