datastore edition mixin' it up - oestrich · 2020-02-17 · datastore edition chris cahoon...
TRANSCRIPT
![Page 1: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/1.jpg)
Mixin' it Up: DatastoreEdition
Chris CahoonEric Oestrich
![Page 2: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/2.jpg)
![Page 3: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/3.jpg)
Using only an object storeon a largeish appand then remembering you can use more than one database in a system
![Page 4: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/4.jpg)
Hierarchical forms & responses
The (Central) Problem
![Page 5: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/5.jpg)
Survey
Question (text)
Question Group
Question (date)
Response
Answer
Answer Group
Answer (date)
Question (phone #) Answer (phone #)
![Page 6: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/6.jpg)
Lots of questionsLots of formsLots of users Lots of responses= Lots of queries
NUMBERS
![Page 7: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/7.jpg)
"We need an object store!"
![Page 8: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/8.jpg)
feels like ActiveRecord inside MongoDB
MONGOID!
![Page 9: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/9.jpg)
![Page 10: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/10.jpg)
"This form belongs_to user!"
![Page 11: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/11.jpg)
"Mongoid has helpers for relations?!"
![Page 12: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/12.jpg)
Response Survey
User
Not bad.
![Page 13: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/13.jpg)
(months pass...)
![Page 14: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/14.jpg)
![Page 15: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/15.jpg)
Response
SurveyUser
Oh.
Organization
Campaign
(etc.) (very etc.)
![Page 16: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/16.jpg)
![Page 17: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/17.jpg)
Mongoid works perfectly for those two models
![Page 18: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/18.jpg)
...but everything else is relational!
![Page 19: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/19.jpg)
![Page 20: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/20.jpg)
There are problems with
object stores
![Page 21: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/21.jpg)
... used like a relational db
(there are things we missed from relational DBs)
![Page 22: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/22.jpg)
Relations
![Page 23: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/23.jpg)
Can only query one collection at
a time
![Page 24: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/24.jpg)
Denormalization
![Page 25: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/25.jpg)
No foreign keys
![Page 26: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/26.jpg)
I accidentally the object
![Page 27: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/27.jpg)
and eat it too?
Can I have my cake?
![Page 28: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/28.jpg)
![Page 29: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/29.jpg)
Just Mongoid
![Page 30: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/30.jpg)
Querying# 2 queriessurveys = Survey.where(:campaign_id.in =>
@user.campaigns.map(&:id)) survey_ids = surveys.map(&:id) # + 1 queryResponse.where(:survey_id.in => survey_ids,
:complete => true).first.answers
# = 3 total queries for search, not chainable
![Page 31: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/31.jpg)
Interlude
![Page 32: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/32.jpg)
![Page 33: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/33.jpg)
Mongoid & ActiveRecord
![Page 34: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/34.jpg)
Bridging the gap
![Page 35: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/35.jpg)
![Page 36: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/36.jpg)
Search with SQL, store with Mongo# 1 queryResponse.
joins(:survey, :campaign).where('complete' => true,
"campaigns.user_id" => @user.id). first.answer_collection
# = 1 total query for search, chainable
![Page 37: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/37.jpg)
![Page 38: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/38.jpg)
![Page 39: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/39.jpg)
Should we gemify this?
![Page 40: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/40.jpg)
GitHub:
https://github.com/oestrich/mixin_it_up_datastore
(look at the branches)
![Page 41: Datastore Edition Mixin' it Up - Oestrich · 2020-02-17 · Datastore Edition Chris Cahoon Eric Oestrich. Using only an object store on a largeish app and then remembering you can](https://reader035.vdocuments.us/reader035/viewer/2022081517/5f02a6117e708231d40550e1/html5/thumbnails/41.jpg)
Thanks