Skip to content

Commit

Permalink
updated based on feedback from PM
Browse files Browse the repository at this point in the history
  • Loading branch information
biozal committed Oct 17, 2024
1 parent 31ff35c commit 5479712
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
7 changes: 2 additions & 5 deletions Capella.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ The "Create a Bucket, Scope, and Collection" dialog will appear. Enter the foll

Click the Create button to create the new Scope and Collection.


## Setup App Services instance

Once you have followed the directions for setting up your cluster, follow the [directions for setting up App Services](https://docs.couchbase.com/cloud/get-started/create-account.html#app-services).
Once you have followed the directions for setting up your bucket, follow the [directions for setting up App Services](https://docs.couchbase.com/cloud/get-started/create-account.html#app-services).

## Setup App Services Endpoint

Expand Down Expand Up @@ -62,9 +61,7 @@ Enter the following information:
- For the App User Name enter: `demo1@example.com`
- For the App User Password enter: `P@ssw0rd12`

Click the chevron for "Configure Access Grants". Click the "Create App User" button to create the App User.

Follow these steps to create a second App User with the following information:
Click the "Create App User" button to create the App User. Follow these steps to create a second App User with the following information:

- For the App User Name enter: `demo2@example.com`
- For the App User Password enter: `P@ssw0rd12`
Expand Down
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ Some UI changes were made to remove wording about Realm and replaced with Couchb

# Requirements
- Xcode 16.0 or later
- Basic SwiftUI knowledge
- Understanding of the Realm SDK for SwiftUI
- Basic [SwiftUI](https://developer.apple.com/xcode/swiftui/) knowledge
- Basic [Swift Concurrency](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/concurrency/) knowledge
- Understanding of the [Realm SDK for SwiftUI](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/swiftui/)

# Fetching the App Source Code

Clone this repository from GitHub using the command line or your Git client:

```bash
git clone https://github.com/couchbaselabs/cbl-realm-template-app-swiftui-todo.git
```

## Capella Configuration
Before running this application, make sure you have [Couchbase Capella App Services](https://docs.couchbase.com/cloud/get-started/configuring-app-services.html) set up.
Expand Down Expand Up @@ -157,6 +166,10 @@ config.replicatorType = .pushAndPull
config.continuous = true
```

> [!TIP]
>The Couchbase Lite SDK [Replication Configuration](https://docs.couchbase.com/couchbase-lite/current/swift/replication.html#lbl-cfg-repl) API also supports [filtering of channels](https://docs.couchbase.com/couchbase-lite/current/swift/replication.html#lbl-repl-chan) to limit the data that is replicated to the device.
>
Authentication to App Services is added to sync information based on the current authenticated user.

```swift
Expand All @@ -165,11 +178,6 @@ let auth = BasicAuthenticator(
password: user.password)
config.authenticator = auth
```

> [!TIP]
>The Couchbase Lite SDK [Replication Configuration](https://docs.couchbase.com/couchbase-lite/current/swift/replication.html#lbl-cfg-repl) API also supports [filtering of channels](https://docs.couchbase.com/couchbase-lite/current/swift/replication.html#lbl-repl-chan) to limit the data that is replicated to the device.
>
#### Replicator Status
A change listener for [Replication Status](https://docs.couchbase.com/couchbase-lite/current/swift/replication.html#lbl-repl-status) is created and is used to track any errors that might happen.

Expand Down Expand Up @@ -241,15 +249,10 @@ Couchbase Lite doesn't have the same security model. In this application the fo

The code of the application was modified to validate that write access is only allowed by users that own the tasks and the Data Access and Validation script was added in the Capella setup instructions that limits whom can write updates.


> [!TIP]
> Develoeprs can use a Custom [Replication Conflict Resolution](https://docs.couchbase.com/couchbase-lite/current/android/conflict.html#custom-conflict-resolution) to receive the result in your applications code and then revert the change.
>


In this conversion, the logic of controlling security was done in the DatabaseService class.

### deleteTask method

The deleteTask method removes a task from the database. This is done by retrieving the document from the database using the `collection.document` function and then calling the collection `delete` function. A security check was added so that only the owner of the task can delete the task.
Expand Down Expand Up @@ -326,8 +329,6 @@ if (taskLiveQueryObserver != nil) {
>Developers should review the Couchbase Capella App Services [channels](https://docs.couchbase.com/cloud/app-services/channels/channels.html) and [roles](https://docs.couchbase.com/cloud/app-services/user-management/create-app-role.html) documentation to understand the security model it provides prior to planning an application migration.
>


### updateItem function
The updateItem function is used to update a task. This is done by retrieving the document from the database using the collection.getDocument method and then updating the document with the new value for the isComplete and summary property. A security check was added so that only the owner of the task can update the task. The document is then saved back to the collection.

Expand Down

0 comments on commit 5479712

Please sign in to comment.