MongoEngine Inside: the Detail of MongoDB & MongoEngine

Abstract

Making MongoDB working does not mean that understanding the details of MongoDB.
Especially when using an ORM library such as MongoEngine, write working codes to query and update data in MongoDB is simple, but apply these codes to large scale environment, it might become disaster. The disaster might be server unresponsive due to long-time query and long-time update, or even worse, corrupt data due to race condition.
I will share some guides related to MongoEngine usage. Hope these guides can help everyone to implement efficient and reliable application which manages huge data by accessing MongoDB via MongoEngine.

Description

1. when MongoEngine 1-1: use PyMongo or use MongoEngine? 2. from ORM to BSON 2-1: read MongoEngine source code to show how MongoEngine read from and .save() to MongoDB 2-2: how MongoEngine automatically dereference ObjectID as embedded document 2-3: .save() help us to write less bytes, but we also need to read less bytes how to pass needed fields use .only() or .exclude() how it affect .save() 3. race condition 3-1: introduce .objects().modify() and .objects().update() 3-2: how ORM design affects your implementation of atomic accessing: 3-2-1: store data in denormalization way (embedded documents): update atomically is trivial but data size is limited 3-2-2: store data in referencing way (independent documents): update atomically need brainstorming 4. index 4-1: index detail 4-1-1: difference between sortable index and hash (non sortable) index 4-1-2: no operation include upsert can ensure unique so if it is an unique field value, apply unique index 4-1-3: some details when indexing array field (including unique index for array field) 4-2: compound index 4-2-1: read query plan to understand what happened when query MongoDB 4-2-2: from 4-2-1 we can understand the gold indexing slogan: equal, sort, range 5. migration tips if can, use .update(multi=True) with some operation based on current value

Slides

https://hackmd.io/p/BkqA55Epf#/

Speaker

郭學聰 (Hsueh-Tsung Kuo)

台灣某game會社的小小RD
目前是CPPRG(C# Perl Python Ruby Golang)熟手
Smalltalk與Scheme基本教義派
不是太奇怪的程式語言都會一些

請多多指教⎝(˶′◡‵˶)⎠