Ошибка TypeError: Cannot read property 'collection' of undefined at C:\Users\123\simple-api\api\index.js:10:18

Учусь node.js

не понимаю, почему выходит ошибка

TypeError: Cannot read property 'collection' of undefined     
at C:\Users\123\simple-api\api\index.js:10:18
const apiBooks = require('./books');

module.exports = function(app, database) {
    app.post('/books', (req, res) => {
        const book = {
          author: req.body.author,
          title: req.body.title,
          text: req.body.text
        };
        database.collection('books').insert(book, (err, result) => {
          if (err) res.send(err);
          else res.send(result.ops[0]);
        });
      })

    app.get('/books/:id', (req, res) => {
        const OdjectID = require('mongodb').ObjectID;
        const id = req.params.id;
        const query = { '_id': new OdjectID(id)}
        database.collection('books').findOne(query, (err, result) => {
            if(err) res.send(err);
            else res.send(result);
        });
    });
}

Ответы (1 шт):

Автор решения: zelmaru

Collection нужно заменить названием коллекции - Books.

→ Ссылка