Dreaming after passing out
Fainting, passing out, and blacking out are all common terms for the same thing, a sudden loss of consciousness of short duration.  The medical term for this is syncope. It is caused by a decrease in blood flow to the brain, limiting the the availability of oxygen and nutrients to the brain cells.  Brain cells have high energy requirements, so this causes them to stop functioning, causing loss of consciousness and muscle tone.

There are many causes of syncope.  In the situation mentioned, a likely possibility is a pressure change in the carotid sinus which is located at the side of the neck. When sensed by a nerve, this can cause primitive parts of the nervous system to change the dilation of blood vessels and the beating of the heart in a manner that brings on syncope.

Dreaming during syncope is not uncommon and that fact may be useful in distinguishing syncope from epileptic seizures according to research by Chiesa et al..