MongoView/MongoView/MongoController.swift

38 lines
723 B
Swift
Raw Normal View History

2020-01-11 19:42:28 +00:00
//
// MongoController.swift
// MongoView
//
// Created by Shadowfacts on 1/8/20.
// Copyright © 2020 Shadowfacts. All rights reserved.
//
import Foundation
import MongoSwift
import NIO
class MongoController {
let connectionString: String
var group: EventLoopGroup!
var client: MongoClient!
init(connectionString: String) {
self.connectionString = connectionString
}
deinit {
try! group.syncShutdownGracefully()
cleanupMongoSwift()
}
func setup() {
print("setting up mongo")
group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
client = try! MongoClient(connectionString, using: group)
}
}