This is a RethinkDB Driver for the Crystal Language.
Add this to your application's shard.yml
:
dependencies:
rethinkdb:
github: CubosTecnologia/rethinkdb.cr
This library is meant to be compactible with RethinkDB's Ruby API. Thus, all official documentation should be valid here. If you find something that behaves differently, please open an issue.
require "rethinkdb"
include RethinkDB::Shortcuts
# Let’s connect and create a table:
conn = r.connect(host: "localhost")
r.db("test").table_create("tv_shows").run(conn)
# Now, let’s insert some JSON documents into the table:
r.table("tv_shows").insert([
{name: "Star Trek TNG", episodes: 178},
{name: "Battlestar Galactica", episodes: 75}
]).run(conn)
# We’ve just inserted two rows into the tv_shows table. Let’s verify the number of rows inserted:
pp r.table("tv_shows").count().run(conn)
# Finally, let’s do a slightly more sophisticated query. Let’s find all shows with more than 100 episodes.
p r.table("tv_shows").filter {|show| show["episodes"] > 100 }.run(conn).to_a
# As a result, we of course get the best science fiction show in existence.
- Fork it ( https://github.com/CubosTecnologia/rethinkdb.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
- Cubos Tecnologia
- lbguilherme - maintainer