A driver for RethinkDB written in Swift.
import RethinkDB
let r = RethinkDB.r
let conn = try! r.connect()
let pool = try! r.pool(size: 15) // creates a connection pool with 15 connections
let conn = try! pool.acquire() // or acquire(timeout: secondsUntilTimeout)
// do stuff with the connection
pool.release(connection: conn)
let locations: Cursor<Document> = try! r.db("test").table("locations").run(conn)
for location in locations {
// do stuff here
}
let location: Document = ["lat": 46.944, "long": 7.447]
try! r.db("test").table("locations").insert(location).run(conn)
let numbers: [Document] = [
["n": 2], ["n": 4], ["n": 8]
]
try! r.db("test").table("numbers").insert(numbers).run(conn)
Check out the API documentation for one of the official drivers.
MIT