python mongoengine高级用法
python mongoengine高级用法
查询
for post in Post.objects(tags='mongodb'):
print(post.title)
num_posts = Post.objects(tags='mongodb').count()
print('Found {} posts with tag "mongodb"'.format(num_posts))
post=Post.objects(tags='mongodb').first()
print(post.title)
使用id查询
post=Post.objects.with_id('5fcdb13a19f9de7f58645bb5')
print(post.title)
不包含查询
# 包含contains 不包含not__contains
# title不包含Fun的post
post= Post.objects.filter(title__not__contains="Fun")
print(post)
https://blog.csdn.net/weixin_42042680/article/details/87909424