Back
MongoKitten

MongoKitten is used by many companies making it a battle-tested library to rely upon.

The API is carefully designed and tweaked and has resulted in a simple yet elegant API.

MongoKitten's query and aggregate builder help you express big queries in a simple and readable way.

import MongoKitten

// Connecting is only as complicated as it needs to be
let database = try Database("mongodb://localhost/awesome-app")
let users = database["users"]

func getOpenKittenDevs() throws {
    guard let joannis = try users.findOne("username" == "Joannis") else {
        print("User 'Joannis' was not found")
        return
    }

    print(String(joannis["github"]["organisation"])) // prints 'OpenKitten'

    for contributor in try users.find("github.organisation" == "OpenKitten" && "username" != "Joannis") {
        print(String(contributor["firstName"])) // Prints "@obbut" and "@lgaches"
    }
}

try getOpenKittenDevs()