我想创建一个使用 pymongos find 函数的函数,但带有用户参数。
class ServiceLog(Document):
# session_id = sessionStart.pk
creation_date = DateTimeField(required=True)
log_level = StringField(required=True)
tag = StringField(required=True)
message = StringField(required=True)
db.service_log.ensure_index(u'log_level', 1)
db.service_log.ensure_index(u'tag', 1)
def log(self, logLevel, taG, messagE, sid):
logging.basicConfig(level=logging.DEBUG)
time = asctime()
ServiceLog(creation_date=time,
log_level=logLevel,
tag=taG,
message=messagE,
session_id=sid).save()
def listLog(self, logLevel, taG, messagE, sid, lim_num, sk_num):
db.log.find(creation_date=time,
log_level=logLevel,
tag=taG,
message=messagE,
session_id=sid).skip(sk_num).limit(lim_num)
如何更改 listLog 以便用户可以输入任意数量的匹配参数?