https://github.com/koombea/couchbase-lite-wrapper-android
https://github.com/koombea/couchbase-lite-wrapper-android
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/koombea/couchbase-lite-wrapper-android
- Owner: koombea
- License: apache-2.0
- Created: 2021-07-13T23:31:22.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-09-16T19:42:54.000Z (10 months ago)
- Last Synced: 2025-09-16T22:02:27.838Z (10 months ago)
- Language: Kotlin
- Size: 258 KB
- Stars: 3
- Watchers: 18
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# couchbase-wrapper-android
[](https://opensource.org/licenses/Apache-2.0)
**Couchbase Lite Wrapper** is a library written in Kotlin that makes it easy for you to implement database CRUD operations with [Couchbase Lite for Android](https://github.com/couchbase/couchbase-lite-android)
## Requirements
- Api 22+
## Installation
Make sure you have the Maven Central repository in root build.gradle:
```groovy
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
```
Then add the dependency with:
```groovy
dependencies {
implementation 'com.github.koombea:couchbase-lite-wrapper-android:2.0.4'
}
```
## The Basics
### Setup
Create a couchbase database for each of the collection you want to store
```kotlin
val couchbaseDatabase = CouchbaseDatabase(context = context, databaseName = "User")
```
Create a couchBaseCollection in order to store documents on it
```kotlin
val couchbaseDatabase = CouchbaseDatabase(context = context, databaseName = "User")
val couchBaseCollection = couchbaseDatabase.createCollection("user")
```
### Create / Update document
```kotlin
val user = User(name = "Brad", lastname = "Depp")
val document = CouchbaseDocument(id = "1", attributes = user)
couchBaseCollection.save(document)
```
### Fetch documents
```kotlin
val expression = Expression.property("attributes.name").equalTo(Expression.string("Brad"))
val documents = couchBaseCollection.fetchAll(whereExpression = expression)
```
### Delete Documents
```kotlin
val expression = Expression.property("attributes.name").equalTo(Expression.string("Brad"))
couchBaseCollection.deleteAll(whereExpression = expression)
```