couchbaselabs / Couchbase Lite C
Licence: apache-2.0
C language bindings for the Couchbase Lite embedded NoSQL database engine
Stars: ✭ 58
Programming Languages
Projects that are alternatives of or similar to Couchbase Lite C
Couchbase Lite Core
Cross-platform C++ core library for Couchbase Lite
Stars: ✭ 187 (+222.41%)
Mutual labels: sync, database, nosql, embedded
Couchbase Lite Ios
Lightweight, embedded, syncable NoSQL database engine for iOS and MacOS apps.
Stars: ✭ 1,532 (+2541.38%)
Mutual labels: sync, database, nosql
Ejdb
🏂 EJDB 2.0 — Embeddable JSON Database engine C library. Simple XPath like query language (JQL). Websockets / Android / iOS / React Native / Flutter / Java / Dart / Node.js bindings. Docker image.
Stars: ✭ 1,187 (+1946.55%)
Mutual labels: database, nosql, embedded
Unqlite
An Embedded NoSQL, Transactional Database Engine
Stars: ✭ 1,583 (+2629.31%)
Mutual labels: database, nosql, embedded
Dbreeze
C# .NET MONO NOSQL ( key value store embedded ) ACID multi-paradigm database management system.
Stars: ✭ 383 (+560.34%)
Mutual labels: database, nosql, embedded
Libmdbx
One of the fastest embeddable key-value ACID database without WAL. libmdbx surpasses the legendary LMDB in terms of reliability, features and performance.
Stars: ✭ 729 (+1156.9%)
Mutual labels: database, nosql
Nodejs Driver
DataStax Node.js Driver for Apache Cassandra
Stars: ✭ 1,074 (+1751.72%)
Mutual labels: database, nosql
Realm Dotnet
Realm is a mobile database: a replacement for SQLite & ORMs
Stars: ✭ 927 (+1498.28%)
Mutual labels: sync, database
Storagedone Android
Kotlin library to make easy using local document-oriented database in Android apps.
Stars: ✭ 18 (-68.97%)
Mutual labels: database, nosql
Xodus
Transactional schema-less embedded database used by JetBrains YouTrack and JetBrains Hub.
Stars: ✭ 864 (+1389.66%)
Mutual labels: database, nosql
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+1136.21%)
Mutual labels: database, nosql
Litedb
LiteDB - A .NET NoSQL Document Store in a single data file - https://www.litedb.org
Stars: ✭ 6,133 (+10474.14%)
Mutual labels: database, nosql
Redis Marshal
Lightweight Redis data exploration tool
Stars: ✭ 16 (-72.41%)
Mutual labels: database, nosql
Restheart
RESTHeart - The REST API for MongoDB
Stars: ✭ 659 (+1036.21%)
Mutual labels: database, nosql
Redix
a persistent real-time key-value store, with the same redis protocol with powerful features
Stars: ✭ 907 (+1463.79%)
Mutual labels: database, nosql
Cosyan
Transactional SQL based RDBMS with sophisticated multi table constraint logic.
Stars: ✭ 45 (-22.41%)
Mutual labels: database, nosql
Couchdb Net
EF Core-like CouchDB experience for .NET!
Stars: ✭ 50 (-13.79%)
Mutual labels: database, nosql
Couchbase Lite For C
This is a cross-platform version of the Couchbase Lite embedded NoSQL syncable database, with a plain C API. The API can be used directly, or as the substrate for binding to other languages like Python, JavaScript or Rust.
What's New (May 2020)
This project is close to beta status. The API is nearly complete and almost all of the functionality is implemented, but there are still missing pieces and only limited testing.
- New Rust and Nim language bindings! They're in the new top-level
bindings
directory. The Python binding has been moved there too. - Added variants of many API functions, which take slices (
FLSlice
) instead of C strings. These are more efficient to call from languages whose native string type is not NUL-terminated, such as Rust. - Added
CBLResultSet_RowArray()
,CBLResultSet_RowDict()
, andCBLResultSet_GetQuery()
. - More of the logging API (in
CBLLog.h
) is implemented, including custom log callbacks. - Updated to latest Couchbase Lite Core (LiteCore).
Goals
- [x] C API
- [x] Similar to to other Couchbase Lite platforms (Java, C#, Swift, Objective-C)
- [x] Clean and regular design
- [x] Comes with a C++ wrapper API, implemented as inline calls to C
- [x] Experimental Python binding (made using
cffi
) - [x] Can be bound to other languages like Go or JavaScript
- [ ] Same feature set as other Couchbase Lite platforms
- [x] Schemaless JSON data model
- [x] Standard CRUD operations
- [x] Efficient binary blob support
- [x] Timed document expiration
- [x] Database encryption (Enterprise Edition only)
- [x] Powerful query language based on Couchbase's N1QL
- [x] Index arbitrary JSON properties or derived expression values
- [x] Full-text search (FTS)
- [x] Multi-master bidirectional replication (sync) with Couchbase Server
- [x] Fast WebSocket-based protocol
- [x] Transfers document deltas for minimal bandwidth
- [x] Replicator event listeners
- [x] Replicator online/offline support and retry behavior
- [x] Replicator TLS/SSL support
- [ ] Peer-to-peer replication
- [x] Schemaless JSON data model
- [x] Minimal platform dependencies: C++ standard library, filesystem, TCP/IP
- [ ] Broad OS support
- [x] macOS, for ease of development
- [x] Common Linux distros, esp. Ubuntu, Fedora, Raspbian (q.v.)
- [x] Windows
- [x] iOS
- [ ] Android (but we have a Couchbase Lite For Android already, with a Java API)
- [x] Runs on Raspberry-Pi-level embedded platforms with…
- 32-bit or 64-bit CPU
- ARM or x86
- Hundreds of MB RAM, hundreds of MHz CPU, tens of MB storage
- Linux-based OS
- Stretch goal: Simpler embedded kernels like mbedOS or ESP-IDF.
Examples
C
// Open a database:
CBLError error;
CBLDatabaseConfiguration config = {"/tmp", kCBLDatabase_Create};
CBLDatabase* db = CBLDatabase_Open("my_db", &config, &error);
// Create a document:
CBLDocument* doc = CBLDocument_New("foo");
FLMutableDict props = CBLDocument_MutableProperties(doc);
FLSlot_SetString(FLMutableDict_Set(dict, FLStr("greeting")), FLStr("Howdy!"));
// Save the document:
const CBLDocument *saved = CBLDatabase_SaveDocument(db, doc,
kCBLConcurrencyControlFailOnConflict,
&error);
CBLDocument_Release(saved);
CBLDocument_Release(doc);
// Read it back:
const CBLDocument *readDoc = CBLDatabase_GetDocument(db, "foo");
FLDict readProps = CBLDocument_Properties(readDoc);
FLSlice greeting = FLValue_AsString( FLDict_Get(readProps, FLStr("greeting")) );
CBLDocument_Release(readDoc);
C++
// Open a database:
cbl::Database db(kDatabaseName, {"/tmp", kCBLDatabase_Create});
// Create a document:
cbl::MutableDocument doc("foo");
doc["greeting"] = "Howdy!";
db.saveDocument(doc);
// Read it back:
cbl::Document doc = db.getMutableDocument("foo");
fleece::Dict readProps = doc->properties();
fleece::slice greeting = readProps["greeting"].asString();
Nim
# Open a database:
let config = DatabaseConfiguration(directory: "/tmp", flags: {DatabaseFlag.create})
var db = openDatabase("nim_db", config)
# Create a document:
var doc = newDocument("foo")
doc["greeting"] = "Howdy!"
db.saveDocument(doc)
# Read it back:
let readDoc = db.getDocument("foo")
let readProps = readDoc.properties
let greeting = readProps["greeting"]
Python
# Open a database:
db = Database("python_db", DatabaseConfiguration("/tmp"));
# Create a document:
doc = MutableDocument("foo")
doc["greeting"] = "Howdy!"
db.saveDocument(doc)
# Read it back:
readDoc = db.getDocument("foo")
readProps = readDoc.properties
greeting = readProps["greeting"]
Rust
// Open a database:
let cfg = DatabaseConfiguration{directory: tmp_dir.path(), flags: CREATE};
let mut db = Database::open("rust_db, Some(cfg)).expect("opening db");
// Create a document:
let mut doc = Document::new_with_id("foo");
let mut props = doc.mutable_properties();
props.at("greeting").put_string("Howdy!");
db.save_document(&mut doc, ConcurrencyControl::FailOnConflict).expect("saving");
// Read it back:
let doc = db.get_document("foo").expect("reload document");
let props = doc.properties();
let greeting = props.get("greeting");
Documentation
- Couchbase Lite documentation is a must-read to learn the architecture and the API concepts, even though the API details are different here.
- C API documentation (generated by Doxygen)
- Or you could just read the header files
- Using Fleece — Fleece is the API for document properties
- Contributor guidelines, should you wish to submit bug fixes, tests, or other improvements
Building It
With CMake on Unix (now including Raspberry Pi!)
Dependencies:
- GCC 7+ or Clang
- CMake 3.9+
- ICU libraries (
apt-get install icu-dev
)
- Clone the repo
- Check out submodules (recursively), i.e.
git submodule update --init --recursive
- Run the shellscript
build.sh
- Run the unit tests, with
test.sh
The library is at build_cmake/libCouchbaseLiteC.so
. (Or .DLL
or .dylib
)
With CMake on Windows
(Much like building on Unix. Details TBD)
With Xcode on macOS
- Clone the repo
- Check out submodules (recursively)
- Open the Xcode project in the
Xcode
subfolder - Select scheme
CBL_C Framework
- Build
The result is CouchbaseLite.framework
in your Xcode Build Products/Debug
directory (the path depends on your Xcode settings.)
To run the unit tests:
- Select scheme
CBL_Tests
- Run
Using It
Generic instructions
- In your build settings, add the paths
include
andvendor/couchbase-lite-core/vendor/fleece/API
(relative to this repo) to your header search paths. - In your linker settings, add the dynamic library.
- In source files, add
#include "cbl/CouchbaseLite.h"
.
With Xcode on macOS
- Add
CouchbaseLite.framework
(see instructions above) to your project. - In source files, add
#include "CouchbaseLite/CouchbaseLite.h"
. - You may need to add a build step to your target, to copy the framework into your app bundle.
Other Language Bindings
-
C++: Already included; see
include/cbl++
- Python: Included but unsupported
- Nim: Included but unsupported
- Rust: Included but unsupported
- Go (Golang): Third-party, in progress.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].