Insert 10 rows into mongodb from html form?

Hi All,

Can anyone help me, I am looking to add 10 rows into a mongodb database from a html form. I have managed to add 1 single row into the database from the form but how would I make it insert 10 and so on 100 also how do I redirect back to the page once I have inserted data into the database it currently shows a blank page with the following

'‘Check the node command prompt for time of execution’

(can this be redirected and shown on my insert.html page

I have the following

HTML - insert.html

   <h1>Intro to Node and MongoDB<h1>    
    <form method="post" action="/addname">
 Email:     <input type="text" name="email" placeholder="Enter Email.." required>
 Name:      <input type="text" name="name" placeholder="Enter Name.." required>
 Website:   <input type="text" name="qebsite" placeholder="Enter Website.." required>
    <input type="submit" value="Add Name">
            <footer>Copyright  </footer>

app.js"/addname", (req, res) => {
  var myData = new User(req.body);
 console.time("item saved to database");
    .then(item => {
      res.send("Check the Node Command Prompt for the time of execution:");
         console.timeEnd("item saved to database");
    .catch(err => {
      res.status(400).send("unable to save to database");


const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
  email: {
    type: String,
  name: {
    type: String,
   qebsite: {
    type: String,

module.exports = mongoose.model('User', userSchema);

I look forward to hearing from you

So… I dont recognize .save() or the User class you’re using there, so it’s a little difficult to say for certain how you’d do multiple submissions short of saying ‘split the fields up and loop through them’.

As far as redirecting back, send a status 303 and the URL to return to in the Location header.

I have added my ‘USER’ model if that helps

And how are you intending to send multiple names, emails, and websites?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.