Skip to content

Commit

Permalink
1.3.1 (#15)
Browse files Browse the repository at this point in the history
* swift-docc-plugin 1.3.0

* async-http-client 1.19.0

* replaced deprecated .createNew with the new .singleton

* Adding _find capability. (#13)

* docs

* tabs

* renames

* added test for find method with body

* docs added

* findError added

* tests renamed

* added test for find method with generic type

* docs

* README updated

* updated dependencies

* docs updated

* try Swift 5.7.1

* Update build-ubuntu.yml

* Swift 5.7.3

* Revert "Swift 5.7.3"

This reverts commit ab8f67a.

* updated dependencies

* Docs updated

* Delete .github/workflows/CodeQL.yml

---------

Co-authored-by: Gregório Gevartosky Torrezan <[email protected]>
  • Loading branch information
makoni and gevartosky authored Feb 24, 2024
1 parent 8e0707c commit c468e89
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 64 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/CodeQL.yml

This file was deleted.

41 changes: 25 additions & 16 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "d029d9d39c87bed85b1c50adee7c41795261a192",
"version" : "1.0.6"
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
Expand All @@ -59,62 +59,62 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "1827dc94bdab2eb5f2fc804e9b0cb43574282566",
"version" : "1.0.2"
"revision" : "12358d55a3824bd5fed310b999ea8cf83a9a1a65",
"version" : "1.0.3"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "532d8b529501fb73a2455b179e0bbb6d49b652ed",
"version" : "1.5.3"
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "702cd7c56d5d44eeba73fdf83918339b26dc855c",
"version" : "2.62.0"
"revision" : "635b2589494c97e48c62514bc8b37ced762e0a62",
"version" : "2.63.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "798c962495593a23fdea0c0c63fd55571d8dff51",
"version" : "1.20.0"
"revision" : "363da63c1966405764f380c627409b2f9d9e710b",
"version" : "1.21.0"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "3bd9004b9d685ed6b629760fc84903e48efec806",
"version" : "1.29.0"
"revision" : "0904bf0feb5122b7e5c3f15db7df0eabe623dd87",
"version" : "1.30.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "320bd978cceb8e88c125dcbb774943a92f6286e9",
"version" : "2.25.0"
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "ebf8b9c365a6ce043bf6e6326a04b15589bd285e",
"version" : "1.20.0"
"revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version" : "1.20.1"
}
},
{
Expand All @@ -125,6 +125,15 @@
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
}
}
],
"version" : 2
Expand Down
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 c468e89

Please sign in to comment.