You should change your model name when creating a new Blog
document:
const newBlog = new Blog({
title: request.body.title,
author: request.body.author,
url: request.body.url,
likes: request.body.likes || 0,
user: currentUser,
});
Also, a good practice would be to check if there are any users in the database before retrieving the first one. This to avoid possible index out of bounds exceptions:
const userDB = await User.find({});
if (userDB.length > 0) {
const currentUser = userDB[0]._id;
...
CLICK HERE to find out more related problems solutions.