1

I am trying to post something to mongodb, my models file looks like this and i have input all of the required fields in insomnia but for some reason it's still not working.

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const contactSchema = new Schema({
  name: { type: String, required: true },
  email: { type: String, required: true },
  phoneNumber: { type: Number, required: true },
  message: { type: String, required: true },
  date: { type: Date, required: false },
}); 


const Contact = mongoose.model('Contact', contactSchema);


module.exports = Contact;
DStewart
  • 73
  • 4
  • I suggest that you add more information to your question, do you have any error logs that might help others to understand the issue? Do you have any other collections that you manage to successfully insert data into? Can you provide the code where you are actually trying to insert data to the collection? – Unnsteinn Garðarsson Sep 04 '20 at 19:46
  • Also for some people reading this that don't know what Insomnia is, you might want to explain that as well. In general you want to write your question by giving all the information you have and everything that you have tried to solve the issue yourself. – Unnsteinn Garðarsson Sep 04 '20 at 19:52

0 Answers0