The oath is to the Constitution

Military officers swear loyalty not to a president or party, but to the Constitution and the American people it protects.