Add support for limiting database result set.
Moved some Zed-specific logic from zedb.js to Zed itself.