Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
MongoEngine models for cross-benchmarks
from mongoengine import *
class ProductList(Document):
name = StringField(required=True, unique=True)
def import_offers(self, offers):
for o in Offer.objects.filter(
for offer in offers:
o = Offer.objects.get(, articlenumber=offer['articlenumber'])
except Offer.DoesNotExist:
o = Offer(, articlenumber=offer['articlenumber'],
o.productlist =
o.title = offer['title']
# Update a bunch of fields
# ...
o.old = False
query = Offer.objects.filter(, old=True)
if query:
class Offer(Document):
articlenumber = StringField(required=True)
title = StringField()
productlist = StringField()
# Define a bunch of fields
# ...
old = BooleanField(default=False)
meta = {
'indexes': [('articlenumber', 'productlist')]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment