Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计通过

vapor-fluent蒸气流

Agent Skill

vapor-fluent 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

210

周安装

9

GitHub Stars

公开资料未说明

下载量

73
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:vapor-fluent(蒸气流)
来源仓库:https://github.com/thepianokid/vapor-fluent-skill
仓库路径:skills/vapor-fluent
安装命令:
npx skills add https://github.com/thepianokid/vapor-fluent-skill --skill vapor-fluent
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/thepianokid/vapor-fluent-skill --skill vapor-fluent

简介

vapor-fluent 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中快速定位候选结果。

  • 它支持根据关键词、任务场景或来源线索进行信息匹配,适用于研究类工作流。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 安装前建议确认权限范围、维护状态及是否触发联网或文件操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Vapor Fluent ORM

Fluent is an ORM framework for Swift used with the Vapor web framework. It leverages Swift's strong type system to provide a type-safe interface for database operations. Instead of writing raw queries, you define model types that represent database structures and use them for CRUD operations.

When to use

Use this skill when:

  • Setting up Fluent in a new or existing Vapor project
  • Defining database models with property wrappers (@ID, @Field, @Parent, @Children, etc.)
  • Writing database migrations
  • Performing CRUD operations (create, read, update, delete)
  • Setting up relations between models (one-to-many, many-to-many)
  • Querying the database with Fluent's query builder
  • Configuring database drivers (PostgreSQL, SQLite, MySQL, MongoDB)

Instructions

1. Add Dependencies

For a new project, use vapor new and answer "yes" to including Fluent. For an existing project, add the Fluent package and a database driver to Package.swift:

// Package dependencies
.package(url: "https://github.com/vapor/fluent.git", from: "4.0.0"),
.package(url: "https://github.com/vapor/fluent-<db>-driver.git", from: "<version>"),

// Target dependencies
.target(name: "App", dependencies: [
    .product(name: "Fluent", package: "fluent"),
    .product(name: "Fluent<Db>Driver", package: "fluent-<db>-driver"),
    .product(name: "Vapor", package: "vapor"),
]),

2. Configure the Database Driver

In configure.swift, import Fluent and the driver, then configure the database connection.

PostgreSQL (recommended):

import Fluent
import FluentPostgresDriver

app.databases.use(
    .postgres(
        configuration: .init(
            hostname: "localhost",
            username: "vapor",
            password: "vapor",
            database: "vapor",
            tls: .disable
        )
    ),
    as: .psql
)

SQLite (good for prototyping):

import Fluent
import FluentSQLiteDriver

// File-based
app.databases.use(.sqlite(.file("db.sqlite")), as: .sqlite)

// In-memory (ephemeral, useful for testing)
app.databases.use(.sqlite(.memory), as: .sqlite)

MySQL / MariaDB:

import Fluent
import FluentMySQLDriver

app.databases.use(.mysql(
    hostname: "localhost",
    username: "vapor",
    password: "vapor",
    database: "vapor"
), as: .mysql)

MongoDB:

import Fluent
import FluentMongoDriver

try app.databases.use(.mongo(connectionString: "<connection string>"), as: .mongo)

PostgreSQL, MySQL, and MongoDB also support connection string URLs:

try app.databases.use(.postgres(url: "<connection string>"), as: .psql)

3. Define Models

Create model classes conforming to Model. Mark them final for performance. Every model needs:

  • A static schema property (table/collection name, snake_case and plural)
  • An @ID field
  • An empty init()
final class Galaxy: Model, Content {
    static let schema = "galaxies"

    @ID(key: .id)
    var id: UUID?

    @Field(key: "name")
    var name: String

    init() { }

    init(id: UUID? = nil, name: String) {
        self.id = id
        self.name = name
    }
}

Key property wrappers for fields:

  • @ID(key:.id) -- unique identifier, use UUID? by default
  • @Field(key: "db_column") -- required stored field
  • @OptionalField(key: "db_column") -- optional stored field
  • @Parent(key: "foreign_key_id") -- belongs-to relation (stores a foreign key)
  • @Children(for: \.$parentField) -- has-many relation (inverse of @Parent)
  • @Siblings(...) -- many-to-many relation via a pivot table
  • @Timestamp(key: "created_at", on:.create) -- auto-managed timestamp

Add Content conformance to return models directly from route handlers.

4. Define Relations

One-to-many (Parent/Children):

On the child model, add a @Parent field:

final class Star: Model, Content {
    static let schema = "stars"

    @ID(key: .id)
    var id: UUID?

    @Field(key: "name")
    var name: String

    @Parent(key: "galaxy_id")
    var galaxy: Galaxy

    init() { }

    init(id: UUID? = nil, name: String, galaxyID: UUID) {
        self.id = id
        self.name = name
        self.$galaxy.id = galaxyID
    }
}

On the parent model, add a @Children property:

// Add to Galaxy model
@Children(for: \.$galaxy)
var stars: [Star]

Note: Access the underlying property wrapper with $ prefix (e.g., self.$galaxy.id = galaxyID).

5. Write Migrations

Create migrations conforming to AsyncMigration to set up database schemas. The prepare method creates/modifies the schema, and revert undoes those changes.

struct CreateGalaxy: AsyncMigration {
    func prepare(on database: Database) async throws {
        try await database.schema("galaxies")
            .id()
            .field("name", .string)
            .create()
    }

    func revert(on database: Database) async throws {
        try await database.schema("galaxies").delete()
    }
}

For models with foreign keys, add a .references constraint:

struct CreateStar: AsyncMigration {
    func prepare(on database: Database) async throws {
        try await database.schema("stars")
            .id()
            .field("name", .string)
            .field("galaxy_id", .uuid, .references("galaxies", "id"))
            .create()
    }

    func revert(on database: Database) async throws {
        try await database.schema("stars").delete()
    }
}

Register migrations in configure.swift in dependency order (parent tables first):

app.migrations.add(CreateGalaxy())
app.migrations.add(CreateStar())

Run migrations from the command line:

swift run App migrate

For in-memory SQLite databases, auto-migrate on startup:

try await app.autoMigrate()

6. Perform CRUD Operations

Create:

app.post("galaxies") { req async throws -> Galaxy in
    let galaxy = try req.content.decode(Galaxy.self)
    try await galaxy.create(on: req.db)
    return galaxy
}

Read all:

app.get("galaxies") { req async throws in
    try await Galaxy.query(on: req.db).all()
}

Read one by ID:

app.get("galaxies", ":id") { req async throws -> Galaxy in
    guard let galaxy = try await Galaxy.find(req.parameters.get("id"), on: req.db) else {
        throw Abort(.notFound)
    }
    return galaxy
}

Update:

app.put("galaxies", ":id") { req async throws -> Galaxy in
    guard let galaxy = try await Galaxy.find(req.parameters.get("id"), on: req.db) else {
        throw Abort(.notFound)
    }
    let updated = try req.content.decode(Galaxy.self)
    galaxy.name = updated.name
    try await galaxy.save(on: req.db)
    return galaxy
}

Delete:

app.delete("galaxies", ":id") { req async throws -> HTTPStatus in
    guard let galaxy = try await Galaxy.find(req.parameters.get("id"), on: req.db) else {
        throw Abort(.notFound)
    }
    try await galaxy.delete(on: req.db)
    return .noContent
}

7. Use Eager Loading for Relations

Use .with(\.$relation) on the query builder to load related models:

app.get("galaxies") { req async throws in
    try await Galaxy.query(on: req.db).with(\.$stars).all()
}

This returns galaxies with their stars nested in the response:

[
    {
        "id": "...",
        "name": "Milky Way",
        "stars": [
            { "id": "...", "name": "Sun", "galaxy": { "id": "..." } }
        ]
    }
]

8. Enable Query Logging (Optional)

To see the generated SQL statements in the console, set the log level to debug in configure.swift:

app.logger.logLevel = .debug

Key Reminders

  • Always mark model classes as final.
  • Every model must have an empty init() {}.
  • Use snake_case and plural names for schema values (e.g., "galaxies", "star_tags").
  • Database field keys in property wrappers should use snake_case (e.g., "galaxy_id").
  • Register migrations in dependency order -- parent tables before child tables.
  • Use $ prefix to access the underlying property wrapper (e.g., $galaxy.id).
  • Add Content conformance to models you want to return directly from route handlers.
  • Do not disable TLS certificate verification in production (MySQL/PostgreSQL).

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

32.41%
按下载量换算24

Claude

31.65%
按下载量换算23

Cursor

19.94%
按下载量换算15

Gemini CLI

8.7%
按下载量换算6

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills