In terms of mechanism, such reactions proceed via the nucleophilic addition giving a hemiaminal -C(OH)(NHR)- intermediate, followed by an elimination of water to yield the imine (see alkylimino-de-oxo-bisubstitution for a detailed mechanism).