MongoDB
相关代码:
if args.get('title'):
filters['title'] = {'$regex': args['title'], '$options': 'i'}
if args.get('unitCode'):
filters['unit_code'] = {'$regex': args['unitCode'], '$options': 'i'}
其中的$regex
表示搜索时,用正则搜索
-》此处含义是:去搜索title
和unitCode
两个字段,且i
表示不区分大小写