Вопрос

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
    }]
});
Это было полезно?

Решение

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

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top