パッケージ、リポジトリ、アプリカテゴリを検索

GitHub リポジトリschultek/stormberry

ストームベリー

Dart コードから簡単に PostgreSQL データベースにアクセスします。

ストームベリー のプロジェクト画像
スター
98
フォーク
25
最終プッシュ(UTC)
2025/10/19
プロジェクト状態
公開中

元の README

以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。

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:

Kilian Schulte GitHub avatar
GitHub 作者

Kilian Schulte ↗

Building cool stuff in Dart & Flutter.

Munich
言語Dart

カテゴリー

このリポジトリが公開するパッケージ

使用している依存関係

依存関係一覧 18 件

プロジェクトに合うリポジトリを選ぶには?

用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。

  1. 名前・作者・説明で検索し、技術トピックで絞り込みます。
  2. スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
  3. 利用前に GitHub で README、ライセンス、Issues を確認します。

情報源と管理

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗