SlideShare a Scribd company logo
MongoDB Mobile
Bringing the Power of MongoDB to Your Device
Matt Lord
Senior Product Manager
@mattalord
We’ve Come a Long
Way
Mobile
Is Transforming Everything
Mobile is becoming not only the new
digital hub, but also the bridge to the
physical world. That’s why mobile will
affect more than just your digital
operations — it will transform your
entire business.
Thomas Husson, Vice President and Principal
Analyst at Forrester Research
A Complete Data Platform
● Geographically distributed backend services
○ MongoDB Atlas
■ Point and click active/active global clusters
■ Effortless HA, DR, and low-latency access
○ MongoDB Stitch, Serverless Platform
■ Automatic scaling based on request volume
■ Stitch Query Anywhere
■ Stitch Functions
■ Stitch Triggers
■ Stitch Mobile Sync (coming soon)
● Geographically distributed frontend services
○ MongoDB Mobile
■ IoT and edge devices
■ iOS and Android apps
■ Supporting local offline storage
● Stitch provides a seamless bridge between them
MongoDB Mobile
The Full Stack
MongoDB Embedded SDK
● A lite version of MongoDB as a library
● C language interface to the library
● Fully passive, no background threads or tasks
MongoDB Drivers
● Swift for iOS, Java for Android
● Existing drivers, extended to support local storage
MongoDB Stitch SDK
● Access to MongoDB Stitch services from Android and iOS
● New Stitch Interfaces for on-device (local) storage
● Synchronization between local and remote
Your Mobile Application
● iOS and Android devices
● Leveraging the power of MongoDB everywhere
● Allowing you to focus on building your GREAT THING
MongoDB Mobile Storage Engine
● K/V storage on top of SQLite
● Very small disk footprint and minimal memory usage
● Energy efficient
Platform Details
Operating System OS Details CPUs Devices
iOS, tvOS 10.2+ ARM64
x86_64 (simulators)
Apple, Inc.
Android 5.0/Lollipop+ x86_64
armeabi-v7a
arm64-v8a
Any vendor
(by ABI)
Linux TBD x86_64 Any vendor
macOS X 10.10+ x86_64 Apple, Inc.
The Full Stack
MongoDB Stitch SDK
● Packages the entire mobile stack together
● Stitches the frontend and backend together
○ End-to-end Mobile SDK
○ API for local storage
○ API for remote Stitch invocation
○ API for syncing between local and remote
○ Provides a transparent bridge for applications
● iOS SDK: https://github.com/mongodb/stitch-ios-sdk/tree/v4-
alpha
● Android SDK: https://github.com/mongodb/stitch-android-
sdk/tree/v4-alpha
final StitchAppClient client = Stitch.getDefaultAppClient();
final MongoClient mongoClient = client.getServiceClient(LocalMongoDbService.ClientFactory);
MongoCollection<Document> items =
mongoClient.getDatabase(TodoItem.TODO_LIST_DATABASE).getCollection(TodoItem.TODO_LIST_COLLECTIO
N);
public void updateChecked(final ObjectId itemId, final boolean isChecked) {
final Document updateDoc = new Document("$set", new Document(TodoItem.CHECKED_KEY, isChecked));
if (isChecked) {
updateDoc.append("$currentDate", new Document(TodoItem.DONE_DATE_KEY, true));
} else {
updateDoc.append("$unset", new Document(TodoItem.DONE_DATE_KEY, ""));
}
items.updateOne(new Document(TodoItem.ID_KEY, itemId), updateDoc);
...
}
private List<TodoItem> getItems() {
final ArrayList<TodoItem> todoItems = new ArrayList<>();
for (final Document doc : items.find()) {
if (TodoItem.isTodoItem(doc)) {
final TodoItem item = new TodoItem(doc);
todoItems.add(item);
}
}
return todoItems;
}
The Full Stack
MongoDB Drivers
● Existing drivers for the given language
○ With a few extensions
■ Open a local storage instance
■ Close a local storage instance
○ Support today for Swift, Java, and C
○ Others created based on demand
● Can be tested directly
○ Swift: https://github.com/mongodb/swift-mongo-
mobile/
○ Java:
http://central.maven.org/maven2/org/mongodb/mongodb-
driver-embedded/
import MongoMobile
…
let client = MongoMobile.create(settings: MongoClientSettings [ dbPath: "test-path" ])
let coll = try client.db("test").collection("foo")
let insertResult = try coll.insertOne([ "test": 42 ])
let findResult = try coll.find([ "_id": insertResult!.insertedId ])
let docs = Array(findResult)
The Full Stack
MongoDB Embedded SDK
● Lite version of MongoDB formed into a library
○ C ABI
○ Auth, Replication, Sharding, etc. removed
○ Supports only the mobile storage engine
○ Passive: no background threads
○ Light: disk, memory, energy
● C Interface
○ Low level
○ Not designed to be used directly
○ Drivers should be extended to invoke it
● Availability
○ Builds out of MongoDB 4.0+ community tree
○ Pre-built binary packages for mobile targets
auto status = mongo_embedded_v1_status_create();
mongo_embedded_v1_init_params params;
...
auto lib = mongo_embedded_v1_lib_init(&params, status);
auto config_yaml = ...
auto instance = mongo_embedded_v1_instance_create(lib,
config_yaml, status);
auto client = mongo_embedded_v1_client_create(instance, status);
auto [inputMessage, inputMessageLen] = ...
auto [output, outputLen] = ...
int err = mongo_embedded_v1_client_invoke(client,
inputMessage, inputMessageLen,
&output, &outputLen,
status);
The Full Stack
Mobile Storage Engine
● Leverages SQLite as a K/V store
○ Single SQLite database called “mobile”
○ Table names follow the WiredTiger filesystem /
dictionary naming convention
○ Every entity you create
■ database, collection, index, ...
■ Stored in a dedicated table as K/V pairs
● Can be tested with standard mongod
./buildscripts/scons.py mongod --mobile-se=on
./build/opt/mongo/mongod --storageEngine=mobile
sqlite> .database
main: /.../mobile.sqlite
sqlite> .tables
_mdb_catalog index-1-1419396644176400596
collection-0-1419396644176400596 index-1-9204882299253173129
collection-0-9204882299253173129
sqlite> select sql from sqlite_master where name='collection-0-9204882299253173129';
CREATE TABLE "collection-0-6881873531296038739"(rec_id INT, data BLOB, PRIMARY
KEY(rec_id))
sqlite> select sql from sqlite_master where name='index-1-9204882299253173129';
CREATE TABLE "index-1-9204882299253173129"(key BLOB PRIMARY KEY, value BLOB)
sqlite> select * from `collection-0-9204882299253173129`;
rec_id data
---------- ----------
1 2
Andrew Morrow
Embedded SDK Lead
Matt Broadstone
Swift Driver Lead
Kaitlin Mahar
Swift Driver Engineer
Ross Lawley
Java Driver Lead
Q&A with the Engineers
Eric Daniels
Stitch Lead
Visit us at the MongoDB Mobile/Stitch booth!
Q&A with the Team
MongoDB Mobile: Bringing the Power of MongoDB to Your Device

More Related Content

Similar to MongoDB Mobile: Bringing the Power of MongoDB to Your Device

Developing an Embedded IoT Solution using Mongoose OS.
Developing an Embedded IoT Solution using Mongoose OS.Developing an Embedded IoT Solution using Mongoose OS.
Developing an Embedded IoT Solution using Mongoose OS.
Emertxe Information Technologies Pvt Ltd
 
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
Xamarin for (not only) Android developers
Xamarin for (not only) Android developersXamarin for (not only) Android developers
Xamarin for (not only) Android developers
Aleksander Piotrowski
 
Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)
Ron Munitz
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
Manuel Carrasco Moñino
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel ToolsXavier Hallade
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
wesley chun
 
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB
 
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
wesley chun
 
Easy IoT with JavaScript
Easy IoT with JavaScriptEasy IoT with JavaScript
Easy IoT with JavaScript
Samsung Open Source Group
 
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB
 
Serverless computing with Google Cloud
Serverless computing with Google CloudServerless computing with Google Cloud
Serverless computing with Google Cloud
wesley chun
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalNAVER D2
 
SumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumit Kataria
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
Arnaud Tournier
 
Serverless Computing with Google Cloud
Serverless Computing with Google CloudServerless Computing with Google Cloud
Serverless Computing with Google Cloud
wesley chun
 

Similar to MongoDB Mobile: Bringing the Power of MongoDB to Your Device (20)

Developing an Embedded IoT Solution using Mongoose OS.
Developing an Embedded IoT Solution using Mongoose OS.Developing an Embedded IoT Solution using Mongoose OS.
Developing an Embedded IoT Solution using Mongoose OS.
 
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local Atlanta: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
 
Xamarin for (not only) Android developers
Xamarin for (not only) Android developersXamarin for (not only) Android developers
Xamarin for (not only) Android developers
 
Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)Headless Android (Wearable DevCon 2014)
Headless Android (Wearable DevCon 2014)
 
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
MongoDB.local DC 2018: MongoDB Mobile: Bringing the Power of MongoDB to Your ...
 
Rapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWTRapid and Reliable Developing with HTML5 & GWT
Rapid and Reliable Developing with HTML5 & GWT
 
Android on IA devices and Intel Tools
Android on IA devices and Intel ToolsAndroid on IA devices and Intel Tools
Android on IA devices and Intel Tools
 
Exploring Google APIs with Python
Exploring Google APIs with PythonExploring Google APIs with Python
Exploring Google APIs with Python
 
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
MongoDB.local Seattle 2019: MongoDB Mobile: Bringing the Power of MongoDB to ...
 
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Sydney 2019: MongoDB Mobile: Bringing the Power of MongoDB to Y...
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Easy IoT with JavaScript
Easy IoT with JavaScriptEasy IoT with JavaScript
Easy IoT with JavaScript
 
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
MongoDB.local Austin 2018: MongoDB Mobile: Bringing the Power of MongoDB to Y...
 
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your DeviceMongoDB Mobile: Bringing the Power of MongoDB to Your Device
MongoDB Mobile: Bringing the Power of MongoDB to Your Device
 
Serverless computing with Google Cloud
Serverless computing with Google CloudServerless computing with Google Cloud
Serverless computing with Google Cloud
 
Kandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_finalKandroid for nhn_deview_20131013_v5_final
Kandroid for nhn_deview_20131013_v5_final
 
SumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststemSumitK's mobile app dev using drupal as base ststem
SumitK's mobile app dev using drupal as base ststem
 
Easing offline web application development with GWT
Easing offline web application development with GWTEasing offline web application development with GWT
Easing offline web application development with GWT
 
Serverless Computing with Google Cloud
Serverless Computing with Google CloudServerless Computing with Google Cloud
Serverless Computing with Google Cloud
 

More from Matt Lord

Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL GiantVitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Matt Lord
 
MongDB Mobile: Bringing the Power of MongoDB to Your Device
MongDB Mobile: Bringing the Power of MongoDB to Your DeviceMongDB Mobile: Bringing the Power of MongoDB to Your Device
MongDB Mobile: Bringing the Power of MongoDB to Your Device
Matt Lord
 
Using MySQL Containers
Using MySQL ContainersUsing MySQL Containers
Using MySQL Containers
Matt Lord
 
Why MySQL High Availability Matters
Why MySQL High Availability MattersWhy MySQL High Availability Matters
Why MySQL High Availability Matters
Matt Lord
 
MySQL High Availability -- InnoDB Clusters
MySQL High Availability -- InnoDB ClustersMySQL High Availability -- InnoDB Clusters
MySQL High Availability -- InnoDB Clusters
Matt Lord
 
Unlocking Big Data Insights with MySQL
Unlocking Big Data Insights with MySQLUnlocking Big Data Insights with MySQL
Unlocking Big Data Insights with MySQL
Matt Lord
 
OpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStackOpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStack
Matt Lord
 
MySQL Group Replication - an Overview
MySQL Group Replication - an OverviewMySQL Group Replication - an Overview
MySQL Group Replication - an Overview
Matt Lord
 
OpenStack and MySQL
OpenStack and MySQLOpenStack and MySQL
OpenStack and MySQL
Matt Lord
 
MySQL DBaaS with OpenStack Trove
MySQL DBaaS with OpenStack TroveMySQL DBaaS with OpenStack Trove
MySQL DBaaS with OpenStack Trove
Matt Lord
 
Getting Started with MySQL Full Text Search
Getting Started with MySQL Full Text SearchGetting Started with MySQL Full Text Search
Getting Started with MySQL Full Text Search
Matt Lord
 
Using MySQL in the Cloud
Using MySQL in the CloudUsing MySQL in the Cloud
Using MySQL in the Cloud
Matt Lord
 
MySQL 5.7 GIS
MySQL 5.7 GISMySQL 5.7 GIS
MySQL 5.7 GIS
Matt Lord
 

More from Matt Lord (13)

Vitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL GiantVitess VReplication: Standing on the Shoulders of a MySQL Giant
Vitess VReplication: Standing on the Shoulders of a MySQL Giant
 
MongDB Mobile: Bringing the Power of MongoDB to Your Device
MongDB Mobile: Bringing the Power of MongoDB to Your DeviceMongDB Mobile: Bringing the Power of MongoDB to Your Device
MongDB Mobile: Bringing the Power of MongoDB to Your Device
 
Using MySQL Containers
Using MySQL ContainersUsing MySQL Containers
Using MySQL Containers
 
Why MySQL High Availability Matters
Why MySQL High Availability MattersWhy MySQL High Availability Matters
Why MySQL High Availability Matters
 
MySQL High Availability -- InnoDB Clusters
MySQL High Availability -- InnoDB ClustersMySQL High Availability -- InnoDB Clusters
MySQL High Availability -- InnoDB Clusters
 
Unlocking Big Data Insights with MySQL
Unlocking Big Data Insights with MySQLUnlocking Big Data Insights with MySQL
Unlocking Big Data Insights with MySQL
 
OpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStackOpenStack Days East -- MySQL Options in OpenStack
OpenStack Days East -- MySQL Options in OpenStack
 
MySQL Group Replication - an Overview
MySQL Group Replication - an OverviewMySQL Group Replication - an Overview
MySQL Group Replication - an Overview
 
OpenStack and MySQL
OpenStack and MySQLOpenStack and MySQL
OpenStack and MySQL
 
MySQL DBaaS with OpenStack Trove
MySQL DBaaS with OpenStack TroveMySQL DBaaS with OpenStack Trove
MySQL DBaaS with OpenStack Trove
 
Getting Started with MySQL Full Text Search
Getting Started with MySQL Full Text SearchGetting Started with MySQL Full Text Search
Getting Started with MySQL Full Text Search
 
Using MySQL in the Cloud
Using MySQL in the CloudUsing MySQL in the Cloud
Using MySQL in the Cloud
 
MySQL 5.7 GIS
MySQL 5.7 GISMySQL 5.7 GIS
MySQL 5.7 GIS
 

MongoDB Mobile: Bringing the Power of MongoDB to Your Device

  • 1. MongoDB Mobile Bringing the Power of MongoDB to Your Device
  • 2. Matt Lord Senior Product Manager @mattalord
  • 3. We’ve Come a Long Way
  • 4. Mobile Is Transforming Everything Mobile is becoming not only the new digital hub, but also the bridge to the physical world. That’s why mobile will affect more than just your digital operations — it will transform your entire business. Thomas Husson, Vice President and Principal Analyst at Forrester Research
  • 5. A Complete Data Platform ● Geographically distributed backend services ○ MongoDB Atlas ■ Point and click active/active global clusters ■ Effortless HA, DR, and low-latency access ○ MongoDB Stitch, Serverless Platform ■ Automatic scaling based on request volume ■ Stitch Query Anywhere ■ Stitch Functions ■ Stitch Triggers ■ Stitch Mobile Sync (coming soon) ● Geographically distributed frontend services ○ MongoDB Mobile ■ IoT and edge devices ■ iOS and Android apps ■ Supporting local offline storage ● Stitch provides a seamless bridge between them
  • 7. The Full Stack MongoDB Embedded SDK ● A lite version of MongoDB as a library ● C language interface to the library ● Fully passive, no background threads or tasks MongoDB Drivers ● Swift for iOS, Java for Android ● Existing drivers, extended to support local storage MongoDB Stitch SDK ● Access to MongoDB Stitch services from Android and iOS ● New Stitch Interfaces for on-device (local) storage ● Synchronization between local and remote Your Mobile Application ● iOS and Android devices ● Leveraging the power of MongoDB everywhere ● Allowing you to focus on building your GREAT THING MongoDB Mobile Storage Engine ● K/V storage on top of SQLite ● Very small disk footprint and minimal memory usage ● Energy efficient
  • 8. Platform Details Operating System OS Details CPUs Devices iOS, tvOS 10.2+ ARM64 x86_64 (simulators) Apple, Inc. Android 5.0/Lollipop+ x86_64 armeabi-v7a arm64-v8a Any vendor (by ABI) Linux TBD x86_64 Any vendor macOS X 10.10+ x86_64 Apple, Inc.
  • 9. The Full Stack MongoDB Stitch SDK ● Packages the entire mobile stack together ● Stitches the frontend and backend together ○ End-to-end Mobile SDK ○ API for local storage ○ API for remote Stitch invocation ○ API for syncing between local and remote ○ Provides a transparent bridge for applications ● iOS SDK: https://github.com/mongodb/stitch-ios-sdk/tree/v4- alpha ● Android SDK: https://github.com/mongodb/stitch-android- sdk/tree/v4-alpha final StitchAppClient client = Stitch.getDefaultAppClient(); final MongoClient mongoClient = client.getServiceClient(LocalMongoDbService.ClientFactory); MongoCollection<Document> items = mongoClient.getDatabase(TodoItem.TODO_LIST_DATABASE).getCollection(TodoItem.TODO_LIST_COLLECTIO N); public void updateChecked(final ObjectId itemId, final boolean isChecked) { final Document updateDoc = new Document("$set", new Document(TodoItem.CHECKED_KEY, isChecked)); if (isChecked) { updateDoc.append("$currentDate", new Document(TodoItem.DONE_DATE_KEY, true)); } else { updateDoc.append("$unset", new Document(TodoItem.DONE_DATE_KEY, "")); } items.updateOne(new Document(TodoItem.ID_KEY, itemId), updateDoc); ... } private List<TodoItem> getItems() { final ArrayList<TodoItem> todoItems = new ArrayList<>(); for (final Document doc : items.find()) { if (TodoItem.isTodoItem(doc)) { final TodoItem item = new TodoItem(doc); todoItems.add(item); } } return todoItems; }
  • 10. The Full Stack MongoDB Drivers ● Existing drivers for the given language ○ With a few extensions ■ Open a local storage instance ■ Close a local storage instance ○ Support today for Swift, Java, and C ○ Others created based on demand ● Can be tested directly ○ Swift: https://github.com/mongodb/swift-mongo- mobile/ ○ Java: http://central.maven.org/maven2/org/mongodb/mongodb- driver-embedded/ import MongoMobile … let client = MongoMobile.create(settings: MongoClientSettings [ dbPath: "test-path" ]) let coll = try client.db("test").collection("foo") let insertResult = try coll.insertOne([ "test": 42 ]) let findResult = try coll.find([ "_id": insertResult!.insertedId ]) let docs = Array(findResult)
  • 11. The Full Stack MongoDB Embedded SDK ● Lite version of MongoDB formed into a library ○ C ABI ○ Auth, Replication, Sharding, etc. removed ○ Supports only the mobile storage engine ○ Passive: no background threads ○ Light: disk, memory, energy ● C Interface ○ Low level ○ Not designed to be used directly ○ Drivers should be extended to invoke it ● Availability ○ Builds out of MongoDB 4.0+ community tree ○ Pre-built binary packages for mobile targets auto status = mongo_embedded_v1_status_create(); mongo_embedded_v1_init_params params; ... auto lib = mongo_embedded_v1_lib_init(&params, status); auto config_yaml = ... auto instance = mongo_embedded_v1_instance_create(lib, config_yaml, status); auto client = mongo_embedded_v1_client_create(instance, status); auto [inputMessage, inputMessageLen] = ... auto [output, outputLen] = ... int err = mongo_embedded_v1_client_invoke(client, inputMessage, inputMessageLen, &output, &outputLen, status);
  • 12. The Full Stack Mobile Storage Engine ● Leverages SQLite as a K/V store ○ Single SQLite database called “mobile” ○ Table names follow the WiredTiger filesystem / dictionary naming convention ○ Every entity you create ■ database, collection, index, ... ■ Stored in a dedicated table as K/V pairs ● Can be tested with standard mongod ./buildscripts/scons.py mongod --mobile-se=on ./build/opt/mongo/mongod --storageEngine=mobile sqlite> .database main: /.../mobile.sqlite sqlite> .tables _mdb_catalog index-1-1419396644176400596 collection-0-1419396644176400596 index-1-9204882299253173129 collection-0-9204882299253173129 sqlite> select sql from sqlite_master where name='collection-0-9204882299253173129'; CREATE TABLE "collection-0-6881873531296038739"(rec_id INT, data BLOB, PRIMARY KEY(rec_id)) sqlite> select sql from sqlite_master where name='index-1-9204882299253173129'; CREATE TABLE "index-1-9204882299253173129"(key BLOB PRIMARY KEY, value BLOB) sqlite> select * from `collection-0-9204882299253173129`; rec_id data ---------- ---------- 1 2
  • 13. Andrew Morrow Embedded SDK Lead Matt Broadstone Swift Driver Lead Kaitlin Mahar Swift Driver Engineer Ross Lawley Java Driver Lead Q&A with the Engineers Eric Daniels Stitch Lead
  • 14. Visit us at the MongoDB Mobile/Stitch booth! Q&A with the Team