move SQL query as function to libertree-db
Merge branch 'master' into xmpp