Fork me on GitHub

ptyhon ORM mongoengine

参考资料:http://www.tuicool.com/articles/bMvI7vN

 

from mongoengine import *
from datetime import datetime


connect('PornHub', host='mongodb://192.168.111.129:27017')

# 定义分类文档
class Categories(Document):
    ' 继承Document类,为普通文档 '
    name = StringField(max_length=30, required=True)
    artnum = IntField(default=0, required=True)
    date = DateTimeField(default=datetime.now(), required=True)


cate = Categories.objects.all()
for c in cate:
   print(c.name)

 

如何使用mongoengine只查询mongo库的部分字段, 而不是全部字段?(待测试)

https://segmentfault.com/q/1010000005143219

posted @ 2017-06-05 22:04  迁梦余光  阅读(229)  评论(0编辑  收藏  举报