38 lines
723 B
Swift
38 lines
723 B
Swift
|
//
|
||
|
// 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)
|
||
|
}
|
||
|
|
||
|
}
|