title: getting the error in mongose Cast to ObjectId failed for value \"{ _id: 'allchatroom' }\" (type Object) at path \"_id\" for model \"user\""
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>module.exports.allchatrooms = async(req, res) =&gt; {
    try {
      const details = await Chatroom.find({});
      return res.status(200).send({
        status: 200,
        message: "all the chatroom",
        data:details,
      });
    }
    catch (error) {
      return res.status(400).send({
        status: 00,
        err: error,
      });
    }
  };</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>error in postman
  
  {
      "status": 400,
      "success": false,
      "err": {
          "stringValue": "\"{ _id: 'allchatroom' }\"",
          "valueType": "Object",
          "kind": "ObjectId",
          "value": {
              "_id": "allchatroom"
          },
          "path": "_id",
          "reason": {},
          "name": "CastError",
          "message": "Cast to ObjectId failed for value \"{ _id: 'allchatroom' }\" (type Object) at path \"_id\" for model \"user\""
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>model file 
  const mongoose = require('mongoose');
  
  const Chatroom =  new mongoose.Schema({
      chatroom_name:{
          type:String,
          require:true
      }
  
   })
   
  module.exports =  mongoose.model('chat',Chatroom);  </code></pre>
  </div>
  </div>
  </p>
  <p>i am try to make the chatroom application for the practice because i am new in this field so try to make this project how can handle the real time data but when i hit the api to get all the chatrooms list then i got this error</p>