Kitura-CouchDB is a pure Swift client which allows Kitura applications to interact with a CouchDB database.
Kitura-CouchDB package to the dependencies within your application’s
Package.swift file. Substitute
"x.x.x" with the latest
.package(url: "https://github.com/IBM-Swift/Kitura-CouchDB.git", from: "x.x.x")
CouchDB to your target's dependencies:
.target(name: "example", dependencies: ["CouchDB"]),
Use Kitura-CouchDB locally
The CouchDBSample executable demonstrates how to create, read, update and delete documents within a CouchDB database in Swift.
Download CouchDB and install.
Set up an admin username and password in CouchDB.
Create a database with the name
Clone this repository:
git clone https://github.com/IBM-Swift/Kitura-CouchDB.git
Update the following code in
Sources\CouchDBSample\main.swiftwith your admin username and password (the host will default to 127.0.0.1 and the port will default to 5984):
let connProperties = ConnectionProperties( host: host, // httpd address port: port, // httpd port secured: secured, // https or http username: nil, // admin username password: nil // admin password )
Open a Terminal window, change into the
Kitura-CouchDBfolder and run
Run the CouchDBSample executable:
You will see informational messages such as "Successfully created the following JSON document in CouchDB:" for each of the operations (create, read, update and delete) performed on the
For a more comprehensive example, you can follow the Kitura tutorial Getting Started with Server-side Swift on raywenderlich.com that shows you how to create a backend API and then link this to a CouchDB instance running on your local machine.
For more information visit our API reference.
We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!
This library is licensed under Apache 2.0. Full license text is available in LICENSE.