Skip to content

Latest commit

 

History

History
64 lines (39 loc) · 980 Bytes

readme.md

File metadata and controls

64 lines (39 loc) · 980 Bytes

mongo db basic

windows client

  • MongoChef

pymongo

Eaxmple document schema

{
    'sha1': '001',
    'time': '2014-12-08T04:02:32.329Z',
    'content': 'abc bcd'
}

{
    'sha1': '002',
    'time': '2015-12-08T04:02:32.329Z',
    'content': 'bax abc ccd'
}

{
    'sha1': '003',
    'time': '2016-12-08T04:02:32.329Z',
    'content': 'axabcdgsdf'
}

Below code all based on this schema.

basic

useful

fuzzy maching by re

import re
rexExp = re.compile('.*' + 'abc' + '.*', re.IGNORECASE)  # 匹配除换行符 \n 之外的任何单字符, 0次或多次
res = db.find({'content':rexExp })  
for rs in res:  
    print(rs)