Skip to content

Instantly share code, notes, and snippets.

@siavashalipour
Created April 10, 2018 23:07
Show Gist options
  • Save siavashalipour/29789b4504d05a73886508927a0cac63 to your computer and use it in GitHub Desktop.
Save siavashalipour/29789b4504d05a73886508927a0cac63 to your computer and use it in GitHub Desktop.
ServerSideSwift - MongoDataBaseService
//
// MongoDBService.swift
// UserAPI
//
// Created by Siavash on 9/4/18.
//
import MongoKitten
struct MongoDataBaseService {
let myDatabase: Database?
init() {
myDatabase = try? MongoKitten.Database("mongodb://localhost/UserAPI")
}
func getCollection() -> MongoKitten.Collection? {
guard let db = myDatabase else { return nil }
return db["Users"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment