Brentford came from behind to beat Sky Bet League Two Dagenham and Redbridge in the Capital One Cup on Tuesday night.