Does Mongoengine provide $ min, $ max field operators?

I use mongoengine and would like to use $ min , $ max (for conditional updates), but I cannot figure out how to do this using the mongoengine interface.

Any help is greatly appreciated.

+4
source share
1 answer

After some digging into the MongoEngine source, I decided to try using the parameter __raw__for the method update(). Using this, I was able to use the field operator $min(a far-fetched, working example):

attribs.objects(name='Mag')[0].update(__raw__={'$min': {'min_value': 4.9}})

This updates the value min_valueif the value 4.9 is <current value min_value.

FWIW, 863 ggoup MongoEngine   $min $max.

+1

All Articles