Skip to content

jjacobson93/RethinkDBSwift

Repository files navigation

RethinkDBSwift

macOS Linux Swift License

A driver for RethinkDB written in Swift.

Usage

Import the module

import RethinkDB

Create a new connection

let r = RethinkDB.r
let conn = try! r.connect()

Connection pool

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)

Query the database

let locations: Cursor<Document> = try! r.db("test").table("locations").run(conn)
for location in locations {
    // do stuff here
}

Insert records

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)

Further reading

Check out the API documentation for one of the official drivers.

License

MIT

About

A RethinkDB driver for Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published