Swiftpack.co -  hummingbird-project/hummingbird-fluent as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Hummingbird integration with Fluent database ORM
.package(url: "https://github.com/hummingbird-project/hummingbird-fluent.git", from: "0.3.2")

Hummingbird Fluent

Hummingbird interface to the Fluent database ORM.

Hummingbird doesn't come with any database drivers or ORM. This library provides a connection to Vapor's database ORM. The Vapor guys have been generous and forward thinking enough to ensure Fluent-kit can be used independent of Vapor. They have a small library that links Vapor to Fluent, this library does pretty much the same thing for Hummingbird.


The following initializes an SQLite database and adds a single migration CreateTodo.

import FluentSQLiteDriver
import HummingbirdFluent

let app = HBApplication()
// add Fluent
// add sqlite database
app.fluent.databases.use(.sqlite(.file("db.sqlite")), as: .sqlite)
// add migrations
// migrate
if arguments.migrate {
    try app.fluent.migrate().wait()

In general the interface to Fluent follows the same pattern as Vapor, except the db and migrations objects are only accessible from within the fluent object, and you need to call HBApplication.addFluent() at initialization.

Fluent can be used from a route as follows. The database is accessible via HBRequest.db.

    .get(":id") { request in 
        guard let id = request.parameters.get("id", as: UUID.self) else { return request.failure(HBHTTPError(.badRequest)) }
        return Todo.find(id, on: request.db)

Here we are returning a Todo with an id specified in the path.

You can find more documentation on Fluent here.


Stars: 2
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

9 weeks ago
  • Conform to expectations of persist framework. Where create throws a duplicate error if the key already exists.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API