Make query_by_example useful

The implementation of the function in the current master is not as useful as it could be as it already fetches the data.
I changed the function so it can be used for every query argument of db functions. That way, examples can be used as aggregate query, delete query, set query and so on.

Curently it is save to do these changes as there was no official release of any for of the function.