In 🔥 | Out ❄️ |
---|---|
Swift | Objective C |
SwiftUI | UIKit |
Combine | RxSwift |
Realm | Core Data |
MongoDB Realm Sync (where needed) | Home-baked cross-platform data sync |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a playground for MongoDB for VS Code Extension. | |
// It creates 6 collections that each contain 1 document. All 6 collections | |
// contain the same information but with different field names. This is to | |
// demonstrate the different ways that MongoDB can store the same data and what | |
// impact your design decisions have on document size (and therefore how many | |
// documents can fit in the database cache → performance). | |
use('FieldNames'); | |
const schema1 = db.getCollection('schema1'); | |
const schema2 = db.getCollection('schema2'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Realm from "realm"; | |
// Set your Schema | |
const ListingSchema = { | |
name: "Listing", | |
primaryKey: "_id", | |
properties: { | |
_id: "objectId", | |
location: "string", | |
price: "int", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
init() { | |
loginPublisher | |
.receive(on: DispatchQueue.main) | |
.flatMap { user -> RealmPublishers.AsyncOpenPublisher in | |
self.shouldIndicateActivity = true | |
var realmConfig = user.configuration(partitionValue: "user=\(user.id)") | |
realmConfig.objectTypes = [User.self, Project.self] | |
return Realm.asyncOpen(configuration: realmConfig) | |
} | |
.receive(on: DispatchQueue.main) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import RealmSwift | |
let app = App(id: "tasktracker-xxxxx") // TODO: Set the Realm application ID | |
@main | |
struct swiftui_realmApp: SwiftUI.App { | |
@StateObject var state = AppState() | |
var body: some Scene { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git clone https://github.com/ClusterDB/task-tracker-swiftui.git | |
cd task-tracker-swiftui | |
pod install --repo-update | |
open task-tracker-swiftui.xcworkspace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"collections": [ | |
{ | |
"_comment": "Customer collection", | |
"customerID": 123456, | |
"name": { | |
"title": "Mr", | |
"first": "Andrew", | |
"last": "Morgan" | |
}, | |
"_passwordComment": "No need for user credentials as will use Google auth", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.freedom.find( | |
{ | |
acidTransaction: "NOW_ENABLED", | |
multiStatement: true, | |
familiarity: "like relational DB", | |
comfortFactor: "🧸 extra cuddly", | |
syntax: "oh so similar", | |
implementation: "even your gran could do it", | |
useCases: "wide open", | |
try: "MongoDB 4.0 today" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymongo import MongoClient | |
def addUser(database, user): | |
return database.customers.insert_one(user).inserted_id | |
client = MongoClient(port=27017) | |
db=client.store | |
# This is the object that the application would be working with anyway and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mysql.connector | |
from mysql.connector import errorcode | |
def addUser(connection, user): | |
cursor = connection.cursor() | |
customerInsert = ( | |
"INSERT INTO customer (first_name, last_name, email, " | |
"DOB, annual_spend) VALUES " | |
"(%(first)s, %(last)s, %(email)s, %(dob)s, %(spend)s)") |
NewerOlder