搜尋套件、儲存庫與 APP 分類

套件詳情v0.18.0

stormberry

一個強類型的 PostgreSQL ORM,可輕鬆在您的 Dart 類和 PostgreSQL 資料庫之間建立綁定。

AndroidiOSmacOSWindowsLinux
近 30 天下載
258
喜歡數
138
Pub 分數
150

安裝套件

flutter pub add stormberry

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Stormberry 是一個強類型的 Dart PostgreSQL ORM,可簡化 Dart 類與 PostgreSQL 資料庫表格之間的對應關係。它提供類型安全的查詢與架構管理,減少重複程式碼並最小化執行時錯誤。專為尋求在 Flutter 與 Dart 應用中實現可靠、可維護資料庫互動的開發者設計,Stormberry 透過清晰直覺的 API 與 PostgreSQL 無縫整合。該套件支援多個平台,包括 Android、iOS、macOS、Windows 與 Linux,非常適合需要強大後端資料處理能力的跨平台應用。

適用情境

  • 使用 PostgreSQL 後端建構跨平台應用程式
  • Flutter 中類型安全的資料庫操作
  • 自動化模式遷移
  • 減少資料層程式碼中的樣板程式碼
  • 將 PostgreSQL 與 Dart 服務整合

主要特色

  • 強類型實體映射
  • 查詢的編譯時安全性
  • 對平台無關資料庫存取的支援
  • 內建遷移工具
  • 乾淨、可讀的查詢語法

適合對象

  • 使用 PostgreSQL 的 Dart/Flutter 開發人員
  • 重視類型安全的團隊
  • 需要可擴展資料層的專案
  • 具有結構化資料模型的後端服務
  • 需要一致的資料庫模式管理的應用程式

使用建議

  • 需要設定 PostgreSQL 伺服器
  • 僅限 PostgreSQL(不包括其他資料庫)
  • ORM 概念的學習曲線
  • 依賴客戶端應用中的穩定網路連接
  • 可能需要為複雜架構進行額外設定

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Stormberry


A strongly-typed postgres ORM to provide easy bindings between your dart classes and postgres database. It supports all kinds of relations without any complex configuration.


Quick Start

To get started, add stormberry as a dependency and build_runner as a dev dependency:

dart pub add stormberry
dart pub add build_runner --dev

In your code, specify an abstract class that should act as a table like this:

// This file is "model.dart"
import 'package:stormberry/stormberry.dart';

// Will be generated by stormberry
part 'model.schema.dart';

@Model()
abstract class User {
  @PrimaryKey()
  String get id;

  String get name;
}

In order to generate the database code, run the following command:

dart run build_runner build

Tip: You'll need to re-run code generation each time you are making changes to your models. During development, you can use watch to automatically watch your changes: dart pub run build_runner watch.

This will generate a .schema.dart file that you should add as a part to the original model file.


Before running your application, you have to migrate your database. To do this run:

dart run stormberry migrate

This will ask you for the connection details of your postgres database and then migrate the database schema by adding the users table.


To access your database from your application, create a Database instance and use the users repository like this:

void main() async {
  
  var db = Database(
    // connection parameters go here
  );
  
  // adds a user to the 'users' table
  await db.users.insertOne(UserInsertRequest(id: 'abc', name: 'Alex'));
  
  // finds a user by its 'id'
  var user = await db.users.queryUser('abc');
  
  assert(user.name == 'Alex');
}

Full Documentation

See the full documentation here or jump directly to the topic you are looking for:

所屬分類

依賴

依賴清單 12 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。