Skip to content
This repository has been archived by the owner on Jul 26, 2019. It is now read-only.

Latest commit

 

History

History
59 lines (42 loc) · 1.17 KB

README.md

File metadata and controls

59 lines (42 loc) · 1.17 KB

rethinkdb.models

⚠ Because I don't use RethinkDB anymore this project is DISCONTINUED ⚠

A really simple ORM (only fetch, save and destroy) for RethinkDB in Crystal

Installation

Add this to your application's shard.yml:

dependencies:
  rethinkdb.models:
    github: BecauseOfProg/rethinkdb.models

Usage

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)

Contributing

  1. Fork it ( https://github.com/BecauseOfProg/rethinkdb.models/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors