'What is The Best way to get date value in JavaScript to send in MongoDB.?
I want to get the date value from React and want to send it to MongoDB using Node.js. What is the best way to get the date value that is suitable for sending to MongoDB.?
Solution 1:[1]
May be like that:
const tourSchema = mongoose.Schema({
title: String,
description: String,
name: String,
creator: String,
tags: [String],
imageFile: String,
**createdAt: {
type: Date,
default: new Date(),
},**
likes: {
type: [String],
default: [],
},
});
ignore **
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alish Madhukar |