Created
October 5, 2011 07:18
-
-
Save reorx/1263846 to your computer and use it in GitHub Desktop.
mongodb usage deom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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