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

パッケージ詳細v0.13.4

faunadb_http

FQL 関数に非常に近いクエリクラスを提供する、FaunaDB クライアントの純粋な Dart 実装。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
94
いいね数
54
Pub ポイント
130

パッケージをインストール

flutter pub add faunadb_http

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

FQL(Fauna Query Language)に非常に近いクエリインターフェースを使用して、データベースとのスムーズな相互作用を可能にする純粋なDartクライアントです。クロスプラットフォームアプリケーション向けに設計されており、モバイル、Web、デスクトップを含むすべての主要プラットフォームをサポートしています。パッケージは、クエリの構築と実行に便利な直感的なDartクラスを提供し、プラットフォーム固有のコードに頼らずにFlutterアプリにFaunaDBを簡単に統合できます。リアルタイムアプリケーションでデータを軽量かつ型安全に管理したい開発者にとって理想的です。

用途

  • リアルタイムアプリデータ同期
  • サーバーレスバックエンド統合
  • クロスプラットフォームデータベースアクセス
  • ユーザー認証システム
  • ドキュメントベースのデータストレージ
  • API駆動型アプリケーションロジック

主な機能

  • 純粋なDart実装
  • FQLに似たクエリ構文
  • クロスプラットフォーム対応
  • 型安全なクエリ構築
  • 軽量で依存関係が最小限
  • 非同期操作

適している対象

  • FaunaDB を使用する Flutter 開発者
  • リアルタイムデータ更新を必要とするアプリ
  • ネイティブプラットフォームコードを回避するプロジェクト
  • 最小限のサーバー要件を持つバックエンドサービス
  • FQLの習熟を好む開発者

注意事項

  • FaunaDB アカウントとAPIキーが必要です
  • FaunaDB の機能セットに制限される
  • オフライン優先機能がありません
  • ネットワーク接続に依存します
  • 本番環境での使用には、追加のエラー処理が必要になる場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

faunadb-http

A pure Dart implementation of a FaunaDB client. This library also provides query classes that closely mimic FQL functions.

Usage

Basic Example
import 'package:faunadb_http/faunadb_http.dart';
import 'package:faunadb_http/query.dart';

void main() async {
  final config = FaunaConfig.build(
    secret: '<your_secret_here>',
  );
  final client = FaunaClient(config);

  final query = Paginate(Match(Index('all_customers')));

  final result = await client.query(query);
  print(result);

  client.close();
}
Writing Queries

After importing the query classes from this package (as in the example above), your queries will look almost identical to FQL.

Check out the FQL Cheat Sheet to see all valid FQL functions.

Example Queries
// segment from example/crud.dart

//
// create
//

final createCollection = CreateCollection(Obj({'name': 'users'}));

final createDocument = Create(
  Collection('users'),
  Obj({
    'data': {'name': 'Gavan Singh'}
  }),
);

final createIndex = CreateIndex(Obj({
  'name': 'user-by-name',
  'source': Collection('users'),
  'terms': [
    {
      'field': ['data', 'name']
    }
  ]
}));

final createFunction = CreateFunction(Obj({
  'name': 'double',
  'body': Query(Lambda('x', Add([Var('x'), Var('x')])))
}));

//
// read
//

final callDoubleFunction = Call(Function_('double'), arguments: 2);

final paginateUsers = Paginate(
  Match(Index('user-by-name'), terms: ['Gavan Singh']),
);

final readUser = Get(Ref(Collection('users'), '281080202238362125'));

final readAllUsers = Map_(
  Paginate(Match(Index('all_Users'))),
  Lambda(
    'userRef',
    Let(
      {
        'userDoc': Get(Var('userRef')),
      },
      Obj(
        {
          'id': Select(['ref', 'id'], Var('userDoc')),
          'name': Select(['data', 'name'], Var('userDoc')),
        },
      ),
    ),
  ),
);

final paginateCollections = Paginate(Collections());

//
// update
//

final updateUser = Update(
  Ref(Collection('users'), '281080202238362125'),
  Obj({
    'data': {'isCool': true}
  }),
);

//
// delete
//

final deleteUser = Delete(Ref(Collection('users'), '281080202238362125'));

Query Differences

There are some cases where your queries will have to be written slightly differently from pure FQL. Here are examples of each type of difference.

  • Optional FQL arguments are named arguments in Dart.

    • Repeat('x', number: 10)
    • Paginate(Collections(), size: 2)
  • FQL functions with a variable number of arguments (such as Sum, GT etc.) accept a Dart List instead.

    • Add([1, Var('x')])
  • Some FQL functions and arguments are reserved keywords in Dart; simply add a trailing underscore to them.

    • Map becomes Map_
    • Function becomes Function_
    • default becomes default_

Build

The json_serializable package provides JSON serialization to the query classes.

Run pub run build_runner build to generate the boilerplate code to add JSON serialization.

pub run build_runner watch is great when trying things out.

Contributors

Can be found in CONTRIBUTORS.md

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。