file = request.files['profile_image']
profile.photo.new_file()
profile.photo.write(file)
profile.photo.close()
profile.photo = current_user.profile.photo
current_user.profile = profile
#Save to DB
current_user.save()
#return all objects
User.objects
#Query in embedded docs
Page.objects(author__country='uk')
#only first 5 people(??throw error if not exist??)
User.objects[:5]
# retrieve first result or None if it doesnt exist
User.objects.first()
for user in User.objects(username='jfuentes'):
print(user.email)
#Query users with age less or equal
Users.objects(age__lte=18)
Page.objects(__raw__={'tags': 'coding'})
class Page(Document):
tags = ListField(StringField())
# This will match all pages that have the word 'coding' as an item in the 'tags' list
Page.objects(tags='coding')