title: "cursor.toArray is not a function""collection.find() accepts at most two arguments""unhandled promise rejections are deprecated" while using .find()
body: <p>I am new to node js and currently i am practicing mongoDB via mongoose 6.0. Here i am getting this error on find method while trying to search the database:</p>
  <pre><code>There was an error
  TypeError: cursor.toArray is not a function
      at model.Query.&lt;anonymous&gt; (C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\lib\query.js:2151:19)
      at model.Query._wrappedThunk [as _find] (C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\lib\helpers\query\wrapThunk.js:27:8)
      at C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\kareem\index.js:370:33
      at processTicksAndRejections (internal/process/task_queues.js:77:11)
  (node:13720) UnhandledPromiseRejectionWarning: MongoInvalidArgumentError: Method &quot;collection.find()&quot; accepts at most two arguments
      at Collection.find (C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\node_modules\mongodb\lib\collection.js:238:19)
      at NativeCollection.&lt;computed&gt; [as find] (C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\lib\drivers\node-mongodb-native\collection.js:191:33)
      at NativeCollection.Collection.doQueue (C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\lib\collection.js:135:23)
      at C:\Users\Ishan\Desktop\Web Dev\Backend lul\FruitsProject\node_modules\mongoose\lib\collection.js:82:24
      at processTicksAndRejections (internal/process/task_queues.js:77:11)
  (Use `node --trace-warnings ...` to show where the warning was created)
  (node:13720) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--u
  terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
  (node:13720) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  </code></pre>
  <p>while trying to read from the database using collection.find() method.</p>
  <pre><code>const mongoose = require('mongoose');
  
  mongoose.connect(&quot;mongodb://localhost:27017/fruitsDB&quot;, {useNewUrlParser: true})
  
  const fruitSchema = new mongoose.Schema ({
    name: String,
    rating: Number,
    review: String
  });
  
  const Fruit = mongoose.model(&quot;Fruit&quot;, fruitSchema); //creates collection
  
  const fruit= new Fruit({
    name: &quot;Apple&quot;,
    rating: 7,
    review: &quot;good&quot;
  });
  
  const kiwi= new Fruit({
    name: &quot;kiwi&quot;,
    rating: 7,
    review: &quot;good&quot;
  });
  
  const banana= new Fruit({
    name: &quot;banana&quot;,
    rating: 7,
    review: &quot;good&quot;
  });
  
  // Fruit.insertMany([kiwi,banana],function(err){
  //   if (err){
  //     console.log(err);
  //   }
  //   else{
  //     console.log(&quot;Successfully inserted&quot;);
  //   }
  // })
  //
  
  Fruit.find(function(err, fruits){ //shows error right here
    if(err){
      console.log(&quot;There was an error&quot;);
      console.log(err);
    }else{
      console.log(fruits);
    }
  }); 
  
  
  </code></pre>
  <p>i even tried downgrading the mongoose version but it still showed the same error.
  The insertion works fine as i practiced it first and later on added that &quot;find&quot; method.</p>