Q:

Selecting most recent data from table

I have a table setup called item_histories, which is setup like below.
+--------------------------------+
|  id  itemId    date    price   |
+--------------------------------+
| 1    2    2015-01-10    310    |
| 2    2    2015-01-11    318    |
| 3    2    2015-01-12    326    |
| 4    2    2015-01-13    333    |
| 5    2    2015-01-14    335    |
| 6    6    2015-01-10    121598 |
| 7    6    2015-01-11    121598 |
| 8    6    2015-01-12    122666 |
| 9    6    2015-01-13    122666 |
| 10   6    2015-01-14    122666 |
+--------------------------------+

I'm trying to select the most recent row for each itemId, like so..
+--------------------------------+
|  id  itemId    date    price   |
+--------------------------------+
| 5    2    2015-01-14    335    |
| 10   6    2015-01-14    122666 |
+--------------------------------+

I'm using Sequelize and this is the code I have now.
db.itemHistory.findAll({
    attributes: [
        'id',
        'price',
        'itemId',
        [db.Sequelize.fn('max', db.Sequelize.col('date')), 'date']
    ],
    group: ['itemId'],
    limit: 1
}).then(function(histories) {
    console.log(histories);
});

Which generated this query, SELECT `id`, `price`, `itemId`, max(`date`) AS `test` FROM `item_histories` AS `itemHistory` GROUP BY `itemId` LIMIT 1.
The MAX(`date`) was my attempt at accomplishing this, but all it does is select the first row, but has a date of the most recent.

A:

If (itemId,date) is UNIQUE in item_histories, you can do something like this:
 SELECT s.id
      , s.price
      , s.itemid
      , s.date
   FROM ( SELECT q.itemid
               , MAX(q.date) AS max_date
            FROM item_histories q
           GROUP BY q.itemid
        ) r
   JOIN item_histories s
     ON s.itemid = r.itemid  
    AND s.date   = r.max_date
  ORDER BY s.itemid

The inline view r returns the maximum value of date for each itemid. You can run that inline view query separately, to see (and confirm) what it returns.
We use the rows returned from that query as if it was a table. (In MySQL terminology, this is actually called a "derived table".)
We perform a join operation back to the item_histories table, to get the rows that have a matching itemid and a date that matches the max_date returned from the inline view.
I noted at the beginning of the answer that this will work as long as (itemid,date) is UNIQUE in the table. If that isn't unique, we have the potential of returning multiple rows which have the same itemid and date.
(Sorry, I can't help you with whatever bizarre syntax Sequelize would need to generate that SQL statement. At the very least, Sequelize should provide some kind of "raw SQL" methods that will let you workaround the limitations.)
(There are other MySQL query patterns that can return an equivalent result.)

FOLLOWUP
To add a join to items table (assuming that itemid is a foreign key referencing item(id)
Repeating the same query from above, the changes (added lines) are between the comment dash lines.
 SELECT s.id
      , s.price
      , s.itemid
      , s.date
 -- ---------------------------------  
      , t.id      AS t_id
      , t.col2    AS t_col2
 -- ---------------------------------   
   FROM ( SELECT q.itemid
               , MAX(q.date) AS max_date
            FROM item_histories q
           GROUP BY q.itemid
        ) r
   JOIN item_histories s
     ON s.itemid = r.itemid  
    AND s.date   = r.max_date
 -- ---------------------------------  
   JOIN items t
     ON t.id = r.itemid
 -- ---------------------------------  
  ORDER BY s.itemid

