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

BecauseOfProg/couchdb-orm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

couchdb-orm

Build Status

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

A simple CouchDB ORM based on TechMagister CouchDB Client

Installation

Add this to your application's shard.yml:

dependencies:
  couchdb-orm:
    github: BecauseOfProg/couchdb-orm

Requirements

  • CouchDB 2.x.x (Tested on CouchDB 2.1.2)
  • Crystal 0.25.x (Tested on Crystal 0.25.1)

Usage

An example explain better than a long text, so

require "couchdb-orm"

CouchDB::ORM::Client.get("http://127.0.0.1:5984") # Mandatory, used everywhere to save, update, destroy

class Animal < CouchDB::ORM::Model

  fields(
    race: String, # name: type
    age: Int32
  )

end

Animal.create_database # Create database, only first time, must be removed once created

animal = Animal.new race: "Dog", age: 5
animal.save # Bool

animal.race = "Cat"
animal.save # Bool

animal2 = Animal.get(animal.id) # Get model from id
animal3 = Animal.get_by(:race, "Cat").first # Get models from field

animal.destroy # Bool

Animal.destroy_database # Destroy database, caution all data is deleted

Contributing

  1. Fork it (https:/BecauseOfProg/couchdb-orm/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

  • Whaxion Whaxion - creator, maintainer

Releases

No releases published

Packages

No packages published