text: // Import the User model
  const { User } = require('../models');
  
  // Define a an object with database query functions
  const UserController = {
      // Get all users from the database
      getAllUser(req, res) {
        User.find({})
          .populate({
            path: 'thoughts',
            select: '-__v'
          })
          .select('-__v')
          .sort({ _id: -1 })
          .then(dbUserData => res.json(dbUserData))
          .catch(err => {
            console.log(err);
            res.sendStatus(400);
          });
      },
  
      // Get one user from the database using the provided ID
      getUserById({ params }, res) {
          User.findOne({ _id: params.id })
          .populate({
              path: 'thoughts',
              select: '-__v'
          })
              .select('-__v')
              .then(dbUserData => res.json(dbUserData))
              .catch(err => {
                  console.log(err);
                  res.sendStatus(400);
              });
      },
  
      // Create a user in the database
      createUser({ body }, res) {
          console.log("Body", body);
          User.create(body)
              .then(dbUserData => res.json(dbUserData))
              .catch(err => res.json(err));
      },
  
      // Update user by id the database using the provided ID
      updateUser({ params, body }, res) {
          User.findOneAndUpdate(
              { _id: params.id }, 
              body, 
              { new: true, runValidators: true })
              .then(dbUserData => {
                  if (!dbUserData) {
                  res.status(404).json({ message: 'No User found with this id!' });
                  return;
                  }
                  res.json(dbUserData);
              })
              .catch(err => res.json(err));
      },
  
      // Delete User from the database using the provided ID
      deleteUser({ params }, res) {
          User.findOneAndDelete({ _id: params.id })
              .then(dbUserData => res.json(dbUserData))
              .catch(err => res.json(err));
      },
  
      // Add a friend to a user in the database using the provided user and friend IDs
      addFriend({ params }, res) {
          User.findOneAndUpdate(
              { _id: params.userId },
              { $push: { friends: params.friendId } },
              { new: true, runValidators: true })
              .then(dbUserData => {
                  if (!dbUserData) {
                  res.status(404).json({ message: 'No user found with this id!' });
                  return;
                  }
                  res.json(dbUserData);
              })
              .catch(err => res.json(err));
      },
  
      // Remove a friend from a user in the database using the provided user and friend IDs
      removeFriend({ params }, res) {
          User.findOneAndUpdate(
                  { _id: params.userId }, 
                  { $pull: { friends: params.friendId } }, 
                  { new: true, runValidators: true })
              .then(dbUserData => {
                  if (!dbUserData) {
                  res.status(404).json({ message: 'No user found with this id!' });
                  return;
                  }
                  res.json(dbUserData);
              })
              .catch(err => res.json(err));
      }
  };
  
  // Export the UserController object
  module.exports = UserController;
  