Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
MongoEngine - NoORM for NoSQL
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Serge Matveenko
February 24, 2013
Programming
290
2
Share
MongoEngine - NoORM for NoSQL
The talk about MongoEngine presented on PyCon Russia 2013.
Serge Matveenko
February 24, 2013
More Decks by Serge Matveenko
See All by Serge Matveenko
Using NSQ in Python
lig
0
140
Build a container on Gitlab CI quest — Game Walkthrough
lig
0
220
Mnj — The MongoDB library which feels good
lig
0
180
Writing Dockerfile for a Python project the right way
lig
0
380
Pyventory for Ansible
lig
0
210
What time is it now?
lig
1
360
100% Test Covɘrage
lig
2
200
What in fact is this Python?
lig
2
210
Mnj — the MongoDB library which does it right
lig
1
300
Other Decks in Programming
See All in Programming
気づいたらRubyで100作品 ー クリエイティブコーディングが生活の一部になるまで / 100 Ruby Sketches Later: How Creative Coding Became Part of My Life
chobishiba
3
510
Oxcを導入して開発体験が向上した話
yug1224
4
260
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
320
iOS26時代の新規アプリ開発
yuukiw00w
0
220
TSKaigi 2026 TypeScriptバックエンドのオブザーバビリティ戦略 — Datadog × NestJSの実践
taiseiyamamotoan
1
210
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
400
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
430
Zod v4 Codec でスキーマに型変換を埋め込む REST API 設計 #TSKaigi2026
ryutaro_yako
0
180
AI駆動開発勉強会 広島支部 第一回勉強会 AI駆動開発概要とワークショップ
hayatoshimiu
0
420
AI開発を加速するためにテスト戦略を言語化した
yoshihiro_shu
0
100
色即是空、空即是色、データサイエンス
kamoneggi
1
260
Modding RubyKaigi for Myself
yui_knk
0
840
Featured
See All Featured
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
570
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.3k
So, you think you're a good person
axbom
PRO
2
2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
55k
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
BBQ
matthewcrist
89
10k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
150
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
130
AI: The stuff that nobody shows you
jnunemaker
PRO
7
670
Information Architects: The Missing Link in Design Systems
soysaucechin
0
950
Transcript
MongoEngine NoORM for NoSQL Serge Matveenko github.com/lig PyCon Russia 2013
Quick MongoDB intro NoSQL document-oriented database • scalable (auto-sharding, replication)
• high-performance (~104-105 queries/sec) • open source (db: AGPL, drivers: Apache)
RDBMS vs MongoDB RDBMS MongoDB data DB + Driver DB
+ PyMongo aggregation constraints Application validation cascade updates business logic Application
RDBMS vs MongoDB RDBMS MongoDB data DB + Driver DB
+ PyMongo aggregation constraints MongoEngine validation cascade updates business logic Application Application
MongoEngine class CharacterName(EmbeddedDocument): first = StringField() last = StringField() class
Character(Document): name = EmbeddedDocumentField(CharacterName) rating = IntField() MongoDB { "_id" : ObjectId ("5125e0ee98764119e77d9b1f"), "_types" : ["Character"], "rating" : 42, "name" : {"_types" : ["CharacterName"], "last": "Connor", "_cls": "CharacterName", "first": "Sarah"}, "_cls": "Character" } How it looks
MongoEngine class CharacterName(EmbeddedDocument): first = StringField() last = StringField() class
Character(Document): name = EmbeddedDocumentField(CharacterName) rating = IntField() MongoDB { "_id" : ObjectId ("5125e0ee98764119e77d9b1f"), "rating" : 42, "name" : {"last": "Connor", "_cls": "CharacterName", "first": "Sarah"}, "_cls": "Character" } How it looks (MongoEngine 0.8)
Simple db.character.find({'name.first': 'John'}) Character.objects(name__first='John') db.character.find({rating: {$gte: 42}}).limit(5) Character.objects(rating__gte=42)[:5] db.character.find({rating: {$exists:
false}}) Character.objects(rating__exists=False) Querying with MongoEngine
Map/Reduce db.character.mapReduce(map_f, reduce_f, {out: 'mr_col'}); db.mr_col.find(); Character.objects.map_reduce(map_f, reduce_f, 'mr_col') Querying
with MongoEngine
Creating db.character.save( {name: {first: 'John', last: 'Conor'}, rating: 42}) jc
= Character( name=CharacterName(first='John', last='Conor'), rating=42) jc.save() Updating with MongoEngine
Atomic updates db.character.update( {name: {first: "John", last: "Conor"}}, {$set: {"name.last":
"Connor"}}) Character.objects( name=CharacterName(first='John', last='Conor') ).update(set__name__last='Connor') Updating with MongoEngine
Under the hood MongoDB "C" BSON Module PyMongo MongoEngine JavaScript
Console Binary data Python native types Declarative classes
Under the hood MongoDB "C" BSON Module PyMongo MongoEngine JavaScript
Console Binary data Python native types Declarative classes
Performance
Out of the box • authentication backend • session engine
• GridFSStorage Third party • stephrdev/django-mongoforms (Model Forms port) • wpjunior/django-mongotools (forms, generic views) • lig/django-registration-me (django-registration port) Django integration
Customizing things (added today. sorry:) • SequenceField(value_decorator=func) • StringField(regex=r'…') •
URLField(verify_exists=True) • … • Inherit from standard Field classes • Write your own Field classes • Inherit from BaseDocument class, don't forget metaclass! • Any metamagic your like…
Questions? Serge Matveenko (github.com/lig) mongoengine.org www.mongodb.org Thanks to Ross Lawley
(github.com/rozza) Elena Voronina :)