ptyhon ORM mongoengine

參考資料:http://www.tuicool.com/articles/bMvI7vNmongodb

 

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/1010000005143219segmentfault

相關文章
相關標籤/搜索