2. This presentation contains “forward-looking statements” within the meaning of Section 27A of the Securities Act of 1933,
as amended, and Section 21E of the Securities Exchange Act of 1934, as amended. Such forward-looking statements are
subject to a number of risks, uncertainties, assumptions and other factors that could cause actual results and the timing of
certain events to differ materially from future results expressed or implied by the forward-looking statements. Factors that
could cause or contribute to such differences include, but are not limited to, those identified our filings with the Securities
and Exchange Commission. You should not rely upon forward-looking statements as predictions of future events.
Furthermore, such forward-looking statements speak only as of the date of this presentation.
In particular, the development, release, and timing of any features or functionality described for MongoDB products
remains at MongoDB’s sole discretion. This information is merely intended to outline our general product direction and it
should not be relied on in making a purchasing decision nor is this a commitment, promise or legal obligation to deliver
any material, code, or functionality. Except as required by law, we undertake no obligation to update any forward-looking
statements to reflect events or circumstances after the date of such statements.
Safe Harbor Statement
5. Stitch: What is it?
• Provide an interface for users to interact
with your app.
• Handle user actions and send requests to
the app server.
• Authenticate users and allow them to use
app features.
• Handle data requests and execute
business logic.
• Store and search persisted application
data.
• Manage data integrity, consistency, and
availability.
6. 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 service invocation
• API for syncing between local and remote
• Provides a transparent bridge for applications
iOS SDK: https://github.com/mongodb/stitch-ios-sdk/
Android SDK: https://github.com/mongodb/stitch-android-sdk/
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_COLLE
CTION);
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;
}
Stitch
8. User Authentication
Built-In Identity Providers
• Anonymous
• Email / Password
• OAuth 2.0 (Facebook & Google)
• API Key (Server & User)
• Custom (Bring Your Own Auth)
Application Users
• Associated with one or more identities
• Must authenticate to send requests
• Trigger authentication events
9. Custom User
/**
* The customer user object relative to our Stitch user that contains
* extended profile information.
*
* @param _id {String} the id of the associated Stitch user
* @param name {String} the chosen username of this user
* @param defaultAvatarOrdinal {Number} 0-7 the default avatar we choose for this user
* @param avatar {Binary?} the uploaded avatar for this user
* @param channelsSubscribedTo {StringArray} the channels this user is subscribed to
*/
export function User(_id, name, defaultAvatarOrdinal, avatar, channelsSubscribedTo) {
return {
_id, name, defaultAvatarOrdinal, avatar, channelsSubscribedTo
};
}
10. Server-Side Rules
Declarative Expressions
• Specify rule conditions with a document
• Access specific request/document values.
Dynamic Evaluation
• Add complex and/or personalized rules with
expansions and operators.
Secure by Default
• If an action does not pass any rule, Stitch
prevents the action
13. ChannelSubscription
/**
* A vector clock that notifies us when a new message has been sent.
*
* @param _id {ObjectId} the unique id of this subscription
* @param ownerId {String} the user id of the owner of this subscription
* @param deviceId {String} the device id of the owner of this subscription
* @param localTimestamp {Numer} the local logical time
* @param remoteTimestamp {Number} the remote logical time
*/
export function ChannelSubscription(_id, channelId, ownerId, subscriptionId, localTimestamp,
remoteTimestamp) {
return {
_id, channelId, ownerId, deviceId: subscriptionId, localTimestamp, remoteTimestamp
};
}
14. ChannelMessage
/**
* A message one would send to a channel.
*
* @param _id {ObjectId} the unique id of the message
* @param channelId {String} the id of the channel this was sent to
* @param content {String} the actual text of the message
* @param sentAt {Number} the time the message was sent to the server or the time the
message hit the server
* @param remoteTimestamp {Number} the logical time of the message (to be updated by the
server trigger)
*/
export function ChannelMessage(_id, ownerId, channelId, content, sentAt, remoteTimestamp) {
return { _id, ownerId, channelId, content, sentAt, remoteTimestamp };
}
22. Functions & Triggers
exports = function(changeEvent) {
// Parse values from the insert change event
// changeEvent.operationType === "INSERT"
const insertedDoc = changeEvent.fullDocument
const { _id, name } = insertedDoc;
// Instantiate a MongoDB service client
const cluster = context.services.get("myCluster");
const myDb = cluster.db("myDb");
const myColl = myDb.collection("myColl");
myColl.updateOne({ _id }, {
"$set": { "someField": "$set" }
})
}
Invoke Serverless Functions
• Written in JavaScript (ES6+)
• Execute dynamically based on context
• Run as a specific application user
• Connect to your application components
• Callable from an SDK or another Function
Trigger Functions on Events
• React to changes in a MongoDB collection
• Execute logic when users are created or log in
• Schedule functions with CRON expressions