Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from pymongo import Connection
- from pymongo.code import Code
- conn = Connection().lab
- col = conn.usage
- def query():
- conn.report.drop()
- m = Code(""" function() { emit({ user : this.user }, { count : 1 }); } """)
- r = Code(""" function(key, vals) { return {count: 1}; } """)
- q = { 'action' : 'push' }
- col.ensure_index("action")
- col.map_reduce(m, r, "report", query = q)
- query()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement