Reputation: 1
var mongoose = require("mongoose");
var articleSchema = new mongoose.Schema({
Title : String,
Image : String,
Description : String,
createdAt : {
type : Date,
default : new Date()
}
});
var article = mongoose.model("Articles", articleSchema);
module.exports = article;
Upvotes: 0
Views: 81
Reputation: 658
const mongoose = require("mongoose");
const articleSchema = mongoose.Schema({
title: { type: String },
image: { type: String },
description: { type: String },
createdAt: { type: Date, default: Date.now }
});
const article = mongoose.model("Articles", articleSchema);
module.exports = article;
https://mongoosejs.com/docs/2.7.x/docs/defaults.html
Upvotes: 1