python using_find_and_modify.py

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python using_find_and_modify.py相关的知识,希望对你有一定的参考价值。

from pymongo import MongoClient

client = MongoClient('localhost', 27017)

db = client.test
counters = db.counters

def get_next_sequence_number(name):
	counter = counters.find_and_modify(query = {'type': name}, update = {'$inc': {'value': 1}}, upsert = True, new = True)
	counter_value = counter['value']
	return counter_value

print get_next_sequence_number('uid')
print get_next_sequence_number('uids')

以上是关于python using_find_and_modify.py的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识