Fluent is a database abstraction layer that makes interacting with databases within swift-libp2p ezpz!
Fluent is an ORM framework for Swift. It takes advantage of Swift's strong type system to provide an easy-to-use interface for your database. Using Fluent centers around the creation of model types which represent data structures in your database. These models are then used to perform create, read, update, and delete operations instead of writing raw queries.
Include the following dependency in your Package.swift file
let package = Package(
...
dependencies: [
...
.package(url: "https://github.com/swift-libp2p/swift-libp2p-fluent.git", .upToNextMinor(from: "0.0.1"))
],
...
.target(
...
dependencies: [
...
.product(name: "Fluent", package: "swift-libp2p-fluent"),
]),
...
)import LibP2P
import Fluent
// import <Your Fluent Driver>
/// Configure your Libp2p networking stack...
let lib = try await Application.make(.detect(), peerID: .ephemeral(.Ed25519))
// To use the database throughout your app
app.databases.use( /*Your database driver*/ )
// To use the configured databse for the peerstore
app.peerstores.use(.fluent)
// To use the configured database for cache
app.caches.use(.fluent)| Name | Description | Build (macOS & Linux) |
|---|---|---|
| ** Supported ** | ||
SQLite |
Fluent driver for SQLite | |
PostgreSQL |
Fluent driver for PostgrSQL | |
MySQL |
Fluent driver for MySQL / MariaDB | |
MongoDB |
Fluent driver for MongoDB | |
| Community Drivers | ||
Github Tag |
A list of all fluent drivers | N/A |
Contributions are welcomed! This code is very much a proof of concept. I can guarantee you there's a better / safer way to accomplish the same results. Any suggestions, improvements, or even just critiques, are welcome!
Let's make this code better together! 🤝
MIT © 2026 Breth Inc.