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

パッケージ詳細v2.8.5

couchbase_lite

Couchbase Lite Community Edition 向けの Flutter プラグイン。Android および iOS でライブ同期とオフライン対応を備えた埋め込み型軽量 NoSQL データベース。

30日間ダウンロード
75
いいね数
46
Pub ポイント
35

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

flutter pub add couchbase_lite

パッケージ概要

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

Couchbase Lite は、Flutter アプリ向けの軽量で埋め込み可能な NoSQL データベースであり、オフラインでのデータ保存とデバイス間のリアルタイム同期を可能にします。モバイルプラットフォーム専用に設計されており、Android および iOS をサポートし、Couchbase Sync Gateway を介してシームレスな同期機能を提供します。このプラグインにより、Couchbase Lite Community Edition が Flutter プロジェクトに統合され、開発者は構造化されたデータをローカルに保存し、接続が復旧した際に変更を同期できます。信頼性の高いオフライン機能とデバイス間の一貫性のあるデータを必要とするアプリケーションに最適です。

用途

  • オフライン優先のモバイルアプリケーション
  • リアルタイムデータ同期
  • モバイルアプリにおけるローカルデータの永続化
  • ローカルデータベースが必要なハイブリッドアプリ
  • デバイス間のデータ一貫性

主な機能

  • 埋め込み型NoSQLデータベース
  • Sync Gateway とのライブ同期
  • 頑丈なオフラインサポート
  • クロスプラットフォーム(Android および iOS)
  • 軽量で高速なパフォーマンス

適している対象

  • オフラインデータが必要なモバイルアプリ開発者
  • リアルタイム同期を必要とするアプリ
  • オフライン対応機能を構築するスタートアップ
  • NoSQLデータモデルを使用するチーム
  • 限られたバックエンドインフラストラクチャを持つプロジェクト

注意事項

  • 完全な同期には Couchbase Sync Gateway が必要です
  • Android および iOS プラットフォームに限定
  • Sync ゲートウェイ統合の追加設定
  • NoSQLスキーマ設計の学習曲線
  • 単純なデータ要件のための潜在的なオーバーヘッド

元の README

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

couchbase_lite plugin

Build Status Coverage Status pub package

A Flutter plugin for Couchbase Lite Community Edition. An embedded lightweight, noSQL database with live synchronization and offline support on Android and iOS.

The goal of this project is to align this library with the Swift SDK API for Couchbase Lite.

Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!

This project forked from Fluttercouch

Getting Started

In your flutter project add the dependency:

dependencies:
  couchbase_lite: ^2.7.1
  
  flutter:
      sdk: flutter

For help getting started with Flutter, view the online documentation

Supported Versions

iOS
Platform Minimum OS version
iOS 10.0 (9.0 - DEPRECATED)
Android
Platform Runtime architectures Minimum API Level
Android armeabi-v7a 22 (19 - DEPRECATED)
Android arm64-v8a 22 (21 - DEPRECATED)
Android x86 22 (19 - DEPRECATED)
Android x86_64 22

API References

Swift SDK API References

Java SDK API References

Note: Syntax follows the Swift SDK but these are the SDKs used for the platform code.

Local Server Setup

Download and setup Couchbase Server / Sync Gateway Community Editions on your local machine the following link

Setup beer-sample database Local Couchbase Server:

  • Add the beer-sample bucket: Settings > Sample Buckets
  • Create a sync_gateway user in the Couchbase Server under Security
  • Give sync_gateway access to the beer-sample

Start Sync Gateway:

~/Downloads/couchbase-sync-gateway/bin/sync_gateway ~/path/to/sync-gateway-config.json

Note: Included in this example is sync-gateway-config.json (Login => u: foo, p: bar)

Usage example

Below is an example for the database using the BLoC pattern ( View <-> BLoC <-> Repository <-> Database )

// Initialize the database
try {
  database = await Database.initWithName("gettingStarted");
} on PlatformException {
  return "Error initializing database";
}

// Create a new document (i.e. a record) in the database.
var mutableDoc = MutableDocument()
    .setDouble("version", 2.0)
    .setString("type", "SDK");

// Save it to the database.
try{
  await database.saveDocument(mutableDoc);
} on PlatformException {
  return "Error saving document";
}

// Update a document.
mutableDoc = (await database.document(mutableDoc.id))?.toMutable()?.setString("language", "Dart");

if (mutableDoc != null) {
  // Save it to the database.
  try {
    await database.saveDocument(mutableDoc);

    var document = await database.document(mutableDoc.id);

    // Log the document ID (generated by the database)
    // and properties
    print("Document ID :: ${document.id}");
    print("Learning ${document.getString("language")}");
  } on PlatformException {
    return "Error saving document";
  }
}

// Create a query to fetch documents of type SDK.
var query = QueryBuilder
    .select([SelectResult.all().from("mydocs")])
    .from("gettingStarted", as: "mydocs")
    .where(Expression.property("type").from("mydocs").equalTo(Expression.string("SDK")));

// Run the query.
try {
  var result = await query.execute();
  print("Number of rows :: ${result.allResults().length}");
} on PlatformException {
  return "Error running the query";
}

// Note wss://10.0.2.2:4984/my-database is for the android simulator on your local machine's couchbase database
// Create replicators to push and pull changes to and from the cloud.
ReplicatorConfiguration config =
ReplicatorConfiguration(database, "ws://10.0.2.2:4984/beer-sample");
config.replicatorType = ReplicatorType.pushAndPull;
config.continuous = true;

// Add authentication.
config.authenticator = BasicAuthenticator("foo", "bar");

// Create replicator (make sure to add an instance or static variable named replicator)
var replicator = Replicator(config);

// Listen to replicator change events.
_listenerToken = replicator.addChangeListener((ReplicatorChange event) {
  if (event.status.error != null) {
    print("Error: " + event.status.error);
  }

  print(event.status.activity.toString());
});

// Start replication.
await replicator.start();

For this getting started guide, you will need to allow using ws protocol.

As of Android Pie, version 9, API 28, cleartext support is disabled, by default. Although wss: protocol URLs are not affected, in order to use the ws: protocol, applications must target API 27 or lower, or must configure application network security as described here.

<application android:usesCleartextTraffic="true">
</application>

App Transport Security is enabled by default since iOS 9 and enforces applications to use HTTPS exclusively. For this getting started guide, you will disable it but we recommend to enable it in production (and enable HTTPS on Sync Gateway). In the Xcode navigator, right-click on Info.plist and open it as a source file.

Append the following inside of the XML tags to disable ATS.

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>

カテゴリー

依存関係

依存関係一覧 4 件

ソースリポジトリ

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

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