Fire up terminal:
sudo vim /System/Library/CoreServices/SystemVersion.plist
and enter your password...
At the bottom of SystemVersion.plist, change:
<key>ProductVersion</key>
<string>10.10</string
to:
<key>ProductVersion</key>
<string>10.9</string>
and then you can proceed with either brew install postgresql
or brew install mongodb
without issue.
###IMPORTANT Remember to revert your changes once you are finished installing, or your system applications, including terminal, will cease to function.