Skip to content

Commit

Permalink
Docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
makoni committed Feb 24, 2024
1 parent 04f3bdd commit bdeedda
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@



This is simple lib to work with CouchDB in Swift.
This is a simple lib to work with CouchDB in Swift.
- Latest version is based on async/await and requires Swift 5.6 and newer. Works with Vapor 4.50 and newer.
- Version 1.0.0 can be used with Vapor 4 without async/await. Swift 5.3 is required
- You can use old version for Vapor 3 from vapor3 branch or using version < 1.0.0.
- You can use the old version for Vapor 3 from vapor3 branch or using version < 1.0.0.

The only depndency for this lib is <a href="https://github.com/swift-server/async-http-client">async-http-client</a>
The only dependency for this lib is <a href="https://github.com/swift-server/async-http-client">async-http-client</a>

## Documentaion
## Documentation

You can find docs, examples and even tutorials [here](https://spaceinbox.me/docs/couchdbclient/documentation/couchdbclient).

Expand Down Expand Up @@ -55,7 +55,7 @@ let couchDBClient = CouchDBClient(
)
```

If you don’t want to have your password in the code you can pass COUCHDB_PASS param in you command line. For example you can run your Server Side Swift project:
If you don’t want to have your password in the code you can pass COUCHDB_PASS param in your command line. For example you can run your Server Side Swift project:
```bash
COUCHDB_PASS=myPassword /path/.build/x86_64-unknown-linux-gnu/release/Run
```
Expand Down Expand Up @@ -113,7 +113,7 @@ try await couchDBClient.update(
print(doc) // doc will have updated name and _rev values now
```

Delete data example:
Delete data:

```swift
let response = try await couchDBClient.delete(fromDb: "databaseName", doc: doc)
Expand Down
2 changes: 1 addition & 1 deletion Sources/CouchDBClient/CouchDBClient.docc/CouchDBClient.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Source code is available on [GitHub](https://github.com/makoni/couchdb-vapor).

CouchDBClient allows you to make simple requests to CouchDB. It's using Swift Concurrency (async/await) and supports Linux, iOS 13+ and macOS 10.15+.

It's using [AsyncHTTPClient](https://github.com/swift-server/async-http-client) which makes it easy to use CouchDBClient for server-side development with Vapor 4.
It's using [AsyncHTTPClient](https://github.com/swift-server/async-http-client) which makes it easy to use CouchDBClient for server-side development with Vapor 4. But it's easy to use it with any iOS or macOS app. Check the Essentials section for examples.

Currently CouchDBClient supports:
- Check if DB exists.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@

@Steps {
@Step {
`CouchDBClient` has an Error enum `CouchDBClientError`. Some of enum values has nested error of `CouchDBError` type that represents error messages from CouchDB.
`CouchDBClient` has an Error enum `CouchDBClientError`. Some enum values have nested errors of `CouchDBError` type that represent error messages from CouchDB.

@Code(name: "main.swift", file: ErrorsHandlingTutorial-1.swift)
}

@Step {
You can wrap your code in do-catch block to catch a CouchDB error during insert operation.
You can wrap your code in a do-catch block to catch a CouchDB error during insert operation.

@Code(name: "main.swift", file: ErrorsHandlingTutorial-2.swift)
}

@Step {
Same for update to find out what's wrong.
Same for updates to find out what's wrong.

@Code(name: "main.swift", file: ErrorsHandlingTutorial-3.swift)
}

@Step {
And same for get operation. CouchDB will return an error message if username or password is incorrect for example.
And same for a get operation. CouchDB will return an error message if the username or password is incorrect for example.

@Code(name: "main.swift", file: ErrorsHandlingTutorial-4.swift)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@Tutorials(name: "CouchDBClient") {
@Intro(title: "Getting started") {
Check tutorials for using the lib in a macOS app or with Vapor for server-side developement.
Check tutorials for using the lib in a macOS app or with Vapor for server-side development.

@Image(source: logo.png, alt: "CouchDBClient logo")
}
Expand All @@ -15,7 +15,7 @@
}

@Chapter(name: "Errors handling") {
Examples handling CouchDBClient errors and errors from CouchDB.
Examples of handling CouchDBClient errors and errors from CouchDB.

@Image(source: chapter1.png, alt: "CouchDBClient logo")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

@Section(title: "Initializaton") {
@ContentAndMedia {
Adding CouchDBClient in your project.
Adding CouchDBClient to your project.

@Image(source: chapter1.png, alt: "Application icon")
}
Expand Down Expand Up @@ -38,7 +38,7 @@
}

@Step {
Define a model for your CouchDB document. It should confirm to `Codable` and `CouchDBRepresentable` protocols.
Define a model for your CouchDB document. It should conform to `Codable` and `CouchDBRepresentable` protocols.

@Code(name: "main.swift", file: macOSTutorial-4.swift)
}
Expand All @@ -50,13 +50,13 @@
}

@Step {
Here's an example of updating the document. CouchDBClient will also update `_rev` value of your document with the value from CouchDB after saving.
Here's an example of updating the document. CouchDBClient will also update the `_rev` value of your document with the value from CouchDB after saving.

@Code(name: "main.swift", file: macOSTutorial-6.swift)
}

@Step {
Getting document by it's `_id` from DB with that method will parse JSON into your model if you'll provide it as a generic type.
Getting a document by its `_id` from DB with that method will parse JSON into your model if you provide it as a generic type.

@Code(name: "main.swift", file: macOSTutorial-7.swift)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
}

@Step {
Define you data model for CouchDB document. Nested `Row` and `RowsResponse` models will be used to parse CouchDB responses.
Define your data model for CouchDB documents. Nested `Row` and `RowsResponse` models will be used to parse CouchDB responses.

@Code(name: "main.swift", file: VaporTutorial-3.swift)
}

@Step {
Get you document from DB. That example is using `CouchDB View` to find the document by url field. It's map function needs `key` param which is `appUrl` in our case.
Get your document from DB. That example is using `CouchDB View` to find the document by the url field. Its map function needs a `key` param which is `appUrl` in our case.

@Code(name: "main.swift", file: VaporTutorial-4.swift)
}
Expand Down

0 comments on commit bdeedda

Please sign in to comment.