def get(self, id=None, callback=None, alias=None, **kwargs):
'''
Gets a single item of the current queryset collection using it's id.
In order to query a different database, please specify the `alias` of the database to query.
'''
from motorengine import Q
if id is None and not kwargs:
raise RuntimeError("Either an id or a filter must be provided to get")
if id is not None:
if not isinstance(id, ObjectId):
id = ObjectId(id)
filters = {
"_id": id
}
else:
filters = Q(**kwargs)
filters = self.get_query_from_filters(filters)
self.coll(alias).find_one(filters, callback=self.handle_get(callback))
评论列表
文章目录