title: how to save data to mongodb schema with object
body: <p>I've been trying to save user data to a mongodb schema, sample schema below, the question is how can i insert data inside the object. Please help i've been doing this for hours</p>
  <p>e.g. User.js</p>
  <pre><code>const mongoose = require('mongoose');
  
  const UserSchema = new mongoose.Schema({
      data:{
          type: String,
          requred: true
      },
      data2:{
          type: String,
          requred: true
      },
      work: {
          industry: String,
          name: String,
          position: String,
      },
      status:{
          type: Boolean,
          default: true,
          requred: true
      },
      subscription:{
          product: String,
          license: String,
          price: String,
          status: Boolean,
          default: false,
          renew: Boolean,
          default : false
      },
      date:{
          type: Date,
          default: Date.now
      }
  });
  
  const User = mongoose.model('User', UserSchema);
  
  module.exports = User;
  </code></pre>
  <p>sample registration handling</p>
  <pre><code>const newUser = new User({
      data1,
      data2,
      work,
      subscription
  });
  
  newUser.save()
  .then(user =&gt; {
      req.flash('success_mg', 'Successfully Registered your can now Login.');
      res.redirect('/login');
  })
  .catch(err =&gt; console.log(err));
  
  </code></pre>