Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

mongodb-developer/Swift-Change-Streams

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Notice: Repository Deprecation

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.

Swift-Change-Streams

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.

Running the App

  1. Open MongoDBSwift.xcodeproj in Xcode
  2. Change the Team value in the Signings & Capabilities tab in the target settings
  3. Wait for the MongoDB Swift driver to download in the background
  4. Build and run the app using ⌘R
  5. If using MongoDB Atlas, create a database user and add your IP address to the Network Access list
  6. Copy the connection string for your MongoDB cluster, paste it into the app (remembering to include the username and password for your database user)

Easter Egg

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 }

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages