cbl
4.0.0, released 2 weeks ago by cbl-dart.dev
An offline-first NoSQL document database with SQL++ queries, full-text search, and bi-directional sync.
What it does
It provides an embedded NoSQL database for Dart and Flutter applications across multiple platforms. It supports SQL++ queries, live reactive queries, full-text search, and peer-to-peer or server data synchronization.
AI-written summary of version 4.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need an offline-first NoSQL database with complex querying capabilities.
- You require bi-directional data synchronization with Couchbase Server or peer-to-peer devices.
- You want reactive live queries that update automatically when data changes.
Skip it when
- You only need a simple key-value store or lightweight local SQLite database.
- You are looking for a standard cloud backend without local offline database requirements.
Strengths
- Supports robust offline-first functionality and local data persistence.
- Offers bi-directional and peer-to-peer data sync features.
- Includes powerful SQL++ query support and live queries.
Weaknesses
- Features like vector search, peer-to-peer sync, and encryption require the Enterprise Edition.
- Involves complex native tooling and FFI setup compared to pure Dart key-value stores.
Setup
- Kind
- FFI (native library)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 12
Add the dependency to pubspec.yaml. Community edition is default, while Enterprise edition requires configuration under hooks in pubspec.yaml.
import 'package:cbl/cbl.dart';
Future<void> main() async {
final database = await Database.openAsync('my-database');
final collection = await database.createCollection('tasks');
await collection.saveDocument(
MutableDocument({'title': 'Learn Couchbase Lite', 'done': false}),
);
final query = await database.createQuery(
"SELECT * FROM tasks WHERE done = false",
);
final results = await (await query.execute()).allResults();
print('Pending tasks: ${results.length}');
await database.close();
}Alternatives
Packages that do the same job and could replace cbl.
- sqflite
Pick if you prefer a traditional local SQLite relational database instead of a NoSQL document database.
96Compare - drift
Pick if you want a type-safe reactive SQLite database builder for Flutter.
99Compare - shared_preferences
Pick if you only need a simple key-value store for preferences instead of a full document database.
97Compare
Works with
Packages commonly used together with cbl: ones it builds on, ones built on it, and its own family.
- archivecbl depends on itEncodes and decodes archive and compression formats such as zip, tar, gzip, and zlib.
- hookscbl depends on itDart API for the JSON-based protocol for package build and link hooks.
- code_assetscbl depends on itProvides the hook protocol specification for bundling native code with Dart packages.
- fficbl depends on itUtilities for working with Foreign Function Interface (FFI) code in Dart.
- stream_channelcbl depends on itAn abstraction for two-way communication channels based on the Dart Stream class.
- characterscbl depends on itUnicode and grapheme cluster aware string manipulation operations for Dart.
- synchronizedcbl depends on itLock mechanism to prevent concurrent access to asynchronous code.
- native_toolchain_ccbl depends on itInvoke the native C compiler installed on the host machine.