Skip to content

Instantly share code, notes, and snippets.

@reorx
Created October 5, 2011 07:18
Show Gist options
  • Select an option

  • Save reorx/1263846 to your computer and use it in GitHub Desktop.

Select an option

Save reorx/1263846 to your computer and use it in GitHub Desktop.
mongodb usage deom
from models import Contact
# 根据条件进行查询
cs = Contact.query(user_id=1) # 返回列表,列表中元素是过core.database.MongoDoc封装的对象
# 添加文档至数据库,返回_id
_id = Contact.create({'user_id':1})
# 根据_id获取MongoDoc对象
_id = ''
c = Contact.get(_id) # 返回的结果是经过core.database.MongoDoc封装的对象
# 对结果c进行更新操作
c.update(group_id=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment