async function seed() {
  await db.sync({ force: true }); // clears db and matches models to tables
  console.log("db synced!");

  let cocktails = [];
  data.drinks.forEach((drink) => {
    let cocktail = {
      name: drink.strDrink,
      imageUrl: drink.strDrinkThumb,
      price: ((Math.ceil(Math.random() * 15) + 5) * 100 - 1) / 100,
    };
    cocktails.push(cocktail);
  });
  const allCocktails = await Promise.all(
    cocktails.map((cocktail) => Cocktail.create(cocktail))
  );

  const allUsers = await Promise.all(
    users.map((user) => {
      const newUser = User.build(user);
      newUser.username = `${newUser.firstName}${newUser.lastName}`;
      newUser.password = "123";
      return newUser.save();
    })
  );

  const adminUser = User.build({});
  adminUser.firstName = "Admin";
  adminUser.lastName = "User";
  adminUser.username = "AdminUser";
  adminUser.email = "adminuser@mail.com";
  adminUser.password = process.env.ADMIN_PASSWORD;
  adminUser.admin = true;
  adminUser.save();

  let memo = {};
  const allOrders = await Promise.all(
    orders.map((order, idx) => {
      const newOrder = Order.build(order);

      if (idx > 150) {
        newOrder.status = "cart";
      } else {
        newOrder.userId = Math.ceil(Math.random() * 100);
        if (memo[newOrder.userId] === true) {
          newOrder.status = "complete";
        } else {
          newOrder.status = "cart";
          memo[newOrder.userId] = true;
        }
      }

      return newOrder.save();
    })
  );

  const createOrderItems = (length) => {
    let array = [];
    for (let i = 0; i < length; i++) {
      const item = {};
      item.quantity = Math.ceil(Math.random() * 5);
      item.cocktailId = Math.ceil(Math.random() * (allCocktails.length - 1));
      item.orderId = Math.ceil(Math.random() * (allOrders.length - 1));
      array.push(item);
    }
    return array;
  };

  const orderItems = createOrderItems(200);
  const allOrderItems = await Promise.all(
    orderItems.map((item) => Order_items.create(item))
  );

  console.log(`seeded ${allOrders.length} orders`);
  console.log(`seeded ${allOrderItems.length} order items`);
  console.log(`seeded ${allUsers.length} users`);
  console.log(`seeded ${allCocktails.length} cocktails`);
  console.log(`seeded successfully`);

  return {
    users: {
      cody: users[0],
      murphy: users[1],
    },
  };
}
/**
 * seed - this function clears the database, updates tables to
 *      match the models, and populates the database.
 */
this function clears the database, updates tables to
match the models, and populates the database.
this function clears the database updates tables to match the models and populates the database .
async function seed() {
  await db.sync({ force: true }); 
  console.log("db synced!");
  let cocktails = [];
  data.drinks.forEach((drink) => {
    let cocktail = {
      name: drink.strDrink,
      imageUrl: drink.strDrinkThumb,
      price: ((Math.ceil(Math.random() * 15) + 5) * 100 - 1) / 100,
    };
    cocktails.push(cocktail);
  });
  const allCocktails = await Promise.all(
    cocktails.map((cocktail) => Cocktail.create(cocktail))
  );
  const allUsers = await Promise.all(
    users.map((user) => {
      const newUser = User.build(user);
      newUser.username = `${newUser.firstName}${newUser.lastName}`;
      newUser.password = "123";
      return newUser.save();
    })
  );
  const adminUser = User.build({});
  adminUser.firstName = "Admin";
  adminUser.lastName = "User";
  adminUser.username = "AdminUser";
  adminUser.email = "adminuser@mail.com";
  adminUser.password = process.env.ADMIN_PASSWORD;
  adminUser.admin = true;
  adminUser.save();
  let memo = {};
  const allOrders = await Promise.all(
    orders.map((order, idx) => {
      const newOrder = Order.build(order);
      if (idx > 150) {
        newOrder.status = "cart";
      } else {
        newOrder.userId = Math.ceil(Math.random() * 100);
        if (memo[newOrder.userId] === true) {
          newOrder.status = "complete";
        } else {
          newOrder.status = "cart";
          memo[newOrder.userId] = true;
        }
      }
      return newOrder.save();
    })
  );
  const createOrderItems = (length) => {
    let array = [];
    for (let i = 0; i < length; i++) {
      const item = {};
      item.quantity = Math.ceil(Math.random() * 5);
      item.cocktailId = Math.ceil(Math.random() * (allCocktails.length - 1));
      item.orderId = Math.ceil(Math.random() * (allOrders.length - 1));
      array.push(item);
    }
    return array;
  };
  const orderItems = createOrderItems(200);
  const allOrderItems = await Promise.all(
    orderItems.map((item) => Order_items.create(item))
  );
  console.log(`seeded ${allOrders.length} orders`);
  console.log(`seeded ${allOrderItems.length} order items`);
  console.log(`seeded ${allUsers.length} users`);
  console.log(`seeded ${allCocktails.length} cocktails`);
  console.log(`seeded successfully`);
  return {
    users: {
      cody: users[0],
      murphy: users[1],
    },
  };
}
async function seed ( ) { await db . sync ( { force : true } ) ; console . log ( "db synced!" ) ; let cocktails = [ ] ; data . drinks . forEach ( ( drink ) => { let cocktail = { name : drink . strDrink , imageUrl : drink . strDrinkThumb , price : ( ( Math . ceil ( Math . random ( ) * 15 ) + 5 ) * 100 - 1 ) / 100 , } ; cocktails . push ( cocktail ) ; } ) ; const allCocktails = await Promise . all ( cocktails . map ( ( cocktail ) => Cocktail . create ( cocktail ) ) ) ; const allUsers = await Promise . all ( users . map ( ( user ) => { const newUser = User . build ( user ) ; newUser . username = ` ${ newUser . firstName } ${ newUser . lastName } ` ; newUser . password = "123" ; return newUser . save ( ) ; } ) ) ; const adminUser = User . build ( { } ) ; adminUser . firstName = "Admin" ; adminUser . lastName = "User" ; adminUser . username = "AdminUser" ; adminUser . email = "adminuser@mail.com" ; adminUser . password = process . env . ADMIN_PASSWORD ; adminUser . admin = true ; adminUser . save ( ) ; let memo = { } ; const allOrders = await Promise . all ( orders . map ( ( order , idx ) => { const newOrder = Order . build ( order ) ; if ( idx > 150 ) { newOrder . status = "cart" ; } else { newOrder . userId = Math . ceil ( Math . random ( ) * 100 ) ; if ( memo [ newOrder . userId ] === true ) { newOrder . status = "complete" ; } else { newOrder . status = "cart" ; memo [ newOrder . userId ] = true ; } } return newOrder . save ( ) ; } ) ) ; const createOrderItems = ( length ) => { let array = [ ] ; for ( let i = 0 ; i < length ; i ++ ) { const item = { } ; item . quantity = Math . ceil ( Math . random ( ) * 5 ) ; item . cocktailId = Math . ceil ( Math . random ( ) * ( allCocktails . length - 1 ) ) ; item . orderId = Math . ceil ( Math . random ( ) * ( allOrders . length - 1 ) ) ; array . push ( item ) ; } return array ; } ; const orderItems = createOrderItems ( 200 ) ; const allOrderItems = await Promise . all ( orderItems . map ( ( item ) => Order_items . create ( item ) ) ) ; console . log ( ` ${ allOrders . length } ` ) ; console . log ( ` ${ allOrderItems . length } ` ) ; console . log ( ` ${ allUsers . length } ` ) ; console . log ( ` ${ allCocktails . length } ` ) ; console . log ( ` ` ) ; return { users : { cody : users [ 0 ] , murphy : users [ 1 ] , } , } ; }
seed - this function clears the database, updates tables to
      match the models, and populates the database.
seed - this function clears the database updates tables to match the models and populates the database .
// clears db and matches models to tables