Updating the user model to store a photo in MongoDB

In order to store the uploaded profile photo directly in the database, we will update the user model to add a photo field that stores the file as data of type Buffer, along with its contentType.

mern-social/server/models/user.model.js:

photo: {    data: Buffer,    contentType: String}

Get Full-Stack React Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.