This repository is deprecated and no longer actively maintained. It contains outdated code examples or practices that do not align with current MongoDB best practices. While the repository remains accessible for reference purposes, we strongly discourage its use in production environments. Users should be aware that this repository will not receive any further updates, bug fixes, or security patches. This code may expose you to security vulnerabilities, compatibility issues with current MongoDB versions, and potential performance problems. Any implementation based on this repository is at the user's own risk. For up-to-date resources, please refer to the MongoDB Developer Center.
This is a super-simple document browser for MongDB. It runs as a desktop client on MongoDB.
The app requests a MongoDB connection string from the user and then lets them browse the databases, collections, and documents in that cluster.
If a document is added, changed, or deleted in the collection being viewed then then the change will be highlighted in the UI. This is a demonstration of how simple it is to use MongoDB Change Streams.
- Open
MongoDBSwift.xcodeproj
in Xcode - Change the
Team
value in theSignings & Capabilities
tab in the target settings - Wait for the MongoDB Swift driver to download in the background
- Build and run the app using
⌘R
- If using MongoDB Atlas, create a database user and add your IP address to the
Network Access
list - Copy the connection string for your MongoDB cluster, paste it into the app (remembering to include the username and password for your database user)
The app is also designed to demonstrate how the MongoDB Swift driver can be used with MongoDB's single collection pattern. With this pattern, documents with different shapes are stored in the same collection - each with a field named "docType" which indicates what shape the structure should match. The pattern is also referred to as "polymorphic collections".
To try that polymorphic behavior out, add these documents to a collection called Collection
in a database named Single
:
{ _id: 'basket1', docType: 'basket', customer: 'cust101' }
{ _id: 'basket1-item1', docType: 'item', name: 'Fish', quantity: 5 }
{ _id: 'basket1-item2', docType: 'item', name: 'Chips', quantity: 3 }