패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.13.4

faunadb_http

FQL 함수와 매우 유사한 쿼리 클래스를 제공하는 순수 Dart 구현의 FaunaDB 클라이언트입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
94
좋아요
54
Pub 점수
130

패키지 설치

flutter pub add faunadb_http

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

FQL(Fauna Query Language)과 매우 유사한 쿼리 인터페이스를 사용하여 데이터베이스와 원활하게 상호작용할 수 있는 순수 Dart 클라이언트입니다. 크로스플랫폼 애플리케이션을 위한 것으로, 모바일, 웹, 데스크톱을 포함한 모든 주요 플랫폼을 지원합니다. 패키지는 쿼리를 구성하고 실행하기 위한 직관적인 Dart 클래스를 제공하여, 플랫폼별 코드에 의존하지 않고도 Flutter 앱에 FaunaDB를 쉽게 통합할 수 있습니다. 실시간 애플리케이션에서 데이터를 가볍고 타입 안전하게 관리하고자 하는 개발자에게 이상적입니다.

사용 사례

  • 실시간 앱 데이터 동기화
  • 서버리스 백엔드 통합
  • 다중 플랫폼 데이터베이스 접근
  • 사용자 인증 시스템
  • 문서 기반 데이터 저장
  • API 기반 애플리케이션 로직

주요 기능

  • 순수한 다트 구현
  • 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.