title: Exporting and importing in Node express
body: <p>I am creating my first project in Node and someone told me that it is a good practise to create a <code>.js</code> file having all the common and frequently used function </p>
  
  <p>For example suppose I want to query something to my mongoose, to fetch data or update data, I should create a <code>js</code> file from where all the operations should happen. </p>
  
  <p>Consider I have a Mongoose Schema which looks like this </p>
  
  <pre><code>const mongoose = require('mongoose')
  
  const userSchema = new mongoose.Schema({
      fullName: String,
      email: String,
      passowrd: String, 
      image: String
  }) 
  
  
  module.exports = mongoose.model('User', userSchema);
  </code></pre>
  
  <p>To perform a function such as checking if the user exsist in the Db, I created a .js file in my helper <code>function folder</code> known as <code>my_db_query.js</code> where I imported my mongoose schema and made  many common function which interact with my schema (or other schemas in my mongoose) </p>
  
  <pre><code>    Const user = requeire(./../model/user.js) 
      //other schema
  
         function findByEmail (email) {
         return User.findOne({email: email}).then((currentUser) =&gt; {
             return currentUser
      } 
  
      function updateUser (updatedData) {
       //to update user
      }
  
      function deleteUser (user) {
     //to delete a user
  }
  </code></pre>
  
  <p>Now, Suppose I have a folder routes where I need to use them. </p>
  
  <pre><code>route.delete("/:delete", isAdmin, (req, res) =&gt; {
  })
  
  route.get("/:id", (req, res) =&gt; {
  })
  
  route.put(/:id, isAdmin, (req, res) =&gt; {
  })
  </code></pre>
  
  <p><strong>Question:</strong> How can I able to export all function at once and how can I import and use them in my routes file</p>