From c75ba7bdac7cdd9749bdc4549b9ade6965c21ca4 Mon Sep 17 00:00:00 2001 From: Jeff Lockhart Date: Mon, 8 Jan 2024 19:44:43 -0700 Subject: [PATCH] Add docs --- couchbase-lite-ee-ktx/README.md | 20 ++++++++++++++++++++ couchbase-lite-ktx/README.md | 20 ++++++++++++++++++++ docs/ktx.md | 20 ++++++++++++++++++++ 3 files changed, 60 insertions(+) diff --git a/couchbase-lite-ee-ktx/README.md b/couchbase-lite-ee-ktx/README.md index cef59fb54..901ecef65 100644 --- a/couchbase-lite-ee-ktx/README.md +++ b/couchbase-lite-ee-ktx/README.md @@ -76,6 +76,26 @@ val document = MutableDocument { database.save(document) ``` +##### Collection creation functions + +You can create a `MutableArray` or `MutableDictionary` using idiomatic `vararg` functions: + +```kotlin +mutableArrayOf("hello", 42, true) +mutableDictOf("key1" to "value1", "key2" to 2, "key3" to null) +``` + +The similar `mutableDocOf` function allows nesting dictionary types, unlike the `MutableDocument` DSL: + +```kotlin +mutableDocOf( + "string" to "hello", + "number" to 42, + "array" to mutableArrayOf(1, 2, 3), + "dict" to mutableDictOf("key" to "value") +) +``` + #### Flow support Supplementing the `Flow` APIs from [Couchbase Lite Android KTX]( diff --git a/couchbase-lite-ktx/README.md b/couchbase-lite-ktx/README.md index 3d8debc9b..e9a2a2369 100644 --- a/couchbase-lite-ktx/README.md +++ b/couchbase-lite-ktx/README.md @@ -76,6 +76,26 @@ val document = MutableDocument { database.save(document) ``` +##### Collection creation functions + +You can create a `MutableArray` or `MutableDictionary` using idiomatic `vararg` functions: + +```kotlin +mutableArrayOf("hello", 42, true) +mutableDictOf("key1" to "value1", "key2" to 2, "key3" to null) +``` + +The similar `mutableDocOf` function allows nesting dictionary types, unlike the `MutableDocument` DSL: + +```kotlin +mutableDocOf( + "string" to "hello", + "number" to 42, + "array" to mutableArrayOf(1, 2, 3), + "dict" to mutableDictOf("key" to "value") +) +``` + #### Flow support Supplementing the `Flow` APIs from [Couchbase Lite Android KTX]( diff --git a/docs/ktx.md b/docs/ktx.md index 7863e5aa8..9cfa667e5 100644 --- a/docs/ktx.md +++ b/docs/ktx.md @@ -86,6 +86,26 @@ val document = MutableDocument { database.save(document) ``` +#### Collection creation functions + +You can create a `MutableArray` or `MutableDictionary` using idiomatic `vararg` functions: + +```kotlin +mutableArrayOf("hello", 42, true) +mutableDictOf("key1" to "value1", "key2" to 2, "key3" to null) +``` + +The similar `mutableDocOf` function allows nesting dictionary types, unlike the `MutableDocument` DSL: + +```kotlin +mutableDocOf( + "string" to "hello", + "number" to 42, + "array" to mutableArrayOf(1, 2, 3), + "dict" to mutableDictOf("key" to "value") +) +``` + ### Flow support Supplementing the `Flow` APIs from [Couchbase Lite Android KTX](