简体   繁体   中英

Retrieve the subset of fields by querying the embedded field

Is it possible to retrieve the subset of fields using Django mongodb nonrel<\/a> . I am totally new to python, but have good knowledge in mongo.

db.Contract.find({'owner.name':'Ram'},{'address':1})

Subobject filters aren't possible yet so you need to drop down to raw_query (which you already figured out). To retrive a subset of fields, use .values('field1', 'field2', ...) .

现在可以使用以下语法按 EmbeddedField 进行过滤:

Contract.objects.filter(owner={'name': 'Ram'})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM