These are chat archives for Automattic/mongoose

28th
Mar 2018
panigrah
@panigrah
Mar 28 2018 00:35
@adamgarcia4 trying to work on this too for a project. I was able to get the multi level comments done but I am yet to figure out how to limit the number of comments returned and fetch more - when there are too many at every level.
Ghost
@ghost~5928d90bd73408ce4f629b9e
Mar 28 2018 13:49
What's the difference between using new Schema vs not using it
const UserPost = ({
    post_id: {
        type: Schema.Types.ObjectId,
        required: true,
        unique: true
    },
});
const UserPost = new Schema({
    post_id: {
        type: Schema.Types.ObjectId,
        required: true,
        unique: true
    }

});
both seems to work..
Kev
@lineus
Mar 28 2018 19:31
@2HexGFX_twitter Schema is 99% of the purpose of mongoose. Schema gives you SchemaTypes which give you validation, indexes, default values, value casting, etc. Schema also gives you collection level (static) methods, document level (instance) methods, query helpers, hooks(middleware), virtuals, and they get compiled into Models. Without Schema, you don't have Models. Check out the user guide