⚠ Because I don't use RethinkDB anymore this project is DISCONTINUED ⚠
A really simple ORM (only fetch, save and destroy) for RethinkDB in Crystal
Add this to your application's shard.yml
:
dependencies:
rethinkdb.models:
github: BecauseOfProg/rethinkdb.models
require "rethinkdb.models"
# Start connection to database
RethinkDB::Db.setup({:host => "rethinkdb"})
# Create Model
class Person < RethinkDB::Model
fields({
name: String, # name: type
age: Int32,
defaults: {age: 15} # defaults: {name: value}
})
end
# Create and save Person
person = Person.new(name: "Oliver", age: 20)
person.save
# Change value of one field
person.name = "Laurent"
person.save
# Destroy
person.destroy
# Fetch a Person
Person.fetch(id)
- Fork it ( https://github.com/BecauseOfProg/rethinkdb.models/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
- Whaxion - creator, maintainer