text: const mongoose = require('mongoose');
  const { Schema } = require('mongoose');
  const bcrypt = require('bcrypt');
  const { Order } = require('./Order')
  //import the bannerSchema
  const Banner = require('./Banner');
  
  const userSchema = new Schema(
      {
          firstName: {
              type: String,
              required: true,
              trim: true
          },
          lastName: {
              type: String,
              required: true,
              trim: true
          },
          email: {
              type: String,
              required: true
          },
          password: {
              type: String,
              required: true,
          },
          orders:{
              type: Schema.Types.Array
          }
      });
  
  //has the user password
  userSchema.pre('save', async function (next) {
      if(this.isNew || this.isModified('password')) {
          const saltRounds = 10;
          this.password = await bcrypt.hash(this.password, saltRounds);
      }
  
      next();
  });
  
  //method to compare and validate password
  userSchema.methods.isCorrectPassword = async function (password) {
      return bcrypt.compare(password, this.password);
  };
  
  const User = mongoose.model('User', userSchema);
  
  module.exports = User;