Skip to content

swift-libp2p/swift-libp2p-fluent

Repository files navigation

Swift LibP2P Fluent

Swift Package Manager compatible Build & Test (macos and linux)

Fluent is a database abstraction layer that makes interacting with databases within swift-libp2p ezpz!

Table of Contents

Overview

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.

Docs & Examples

Install

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"),
            ]),
    ...
)

Usage

Example

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)

Drivers

Name Description Build (macOS & Linux)
** Supported **
SQLite Fluent driver for SQLite Build & Test Drivers
PostgreSQL Fluent driver for PostgrSQL Build & Test Drivers
MySQL Fluent driver for MySQL / MariaDB Build & Test Drivers
MongoDB Fluent driver for MongoDB Build & Test Drivers
Community Drivers
Github Tag A list of all fluent drivers N/A

Contributing

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! 🤝

Credits

License

MIT © 2026 Breth Inc.

About

LibP2P ORM (queries, models, and relations) for NoSQL and SQL databases (from Vapor)

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages