Length of array in jade undefined

11,298

You have typo in your #{restaurant.tables.length} it should be tabels

Share:
11,298
Mohamad Ali
Author by

Mohamad Ali

I want to find new friends that are like me

Updated on June 04, 2022

Comments

  • Mohamad Ali
    Mohamad Ali almost 2 years

    I have code i want to show count of tables in restaurant My code is:

    #{restaurant.tables.length}
    

    But it not works for me and error me "Cannot read property 'length' of undefined".how can i solve this?

    tables is array i fetch from mongodb collection.

    i use mongoosejs "findOne" method, and my restaurant schema is :

     var restuarantSchema = new Schema({
        name : String,
        details : String,
        owner : String,
        categories : {
           name : String
        },
        users : [],
        tabels: [{
            title: String
        }]
    });