Mongoose .find({}) returns empty array


My target is to fetch all documents in "Ingredients" collection but my code returns only empty array.

This is my "Ingredients" collection:
enter image description here

ingredient model file:

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const ingredientSchema = new Schema({
    name: String,
    number: Number

const Ingredient = mongoose.model('Ingredients', ingredientSchema);

module.exports = Ingredient;

ingredients route file:

const router = require('express').Router();
let Ingredients = require('../models/ingredients.model');

router.route('/').get((req, res) => {

    let getIngredients = async function (){
        let ingredients = await Ingredients.find({});

module.exports = router;


OK just fixed it by creating new collection with the name "ingredient" (small letter case) and changed my scheme to this one and now it works.

Answered By – Sergey Arenzon

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published