Allow empty query. Custom encoder to deal with Mongo datetime and ObjectId.