def get(self): database = self.settings['db'] query = utils.unpack_params(self) num = query.pop("num", None) if num: try: docs = database.sample.find().sort('time', direction=pymongo.DESCENDING).limit(num) except pymongo.errors.PyMongoError: raise utils._compose_err_msg(500, '', query) else: try: docs = database.container.find(query).sort('time', direction=pymongo.DESCENDING) except pymongo.errors.PyMongoError: raise utils._compose_err_msg(500, 'Query Failed: ', query) if docs: utils.return2client(self, docs) else: raise utils._compose_err_msg(500, 'No results found!')
def get(self): database = self.settings['db'] query = utils.unpack_params(self) num = query.pop("num", None) if num: try: docs = database.sample.find().sort( 'time', direction=pymongo.DESCENDING).limit(num) except pymongo.errors.PyMongoError: raise utils._compose_err_msg(500, '', query) else: try: docs = database.container.find(query).sort( 'time', direction=pymongo.DESCENDING) except pymongo.errors.PyMongoError: raise utils._compose_err_msg(500, 'Query Failed: ', query) if docs: utils.return2client(self, docs) else: raise utils._compose_err_msg(500, 'No results found!')