ruby on couchdb - simplystored and rockingchair

21
Jonathan Weiss, 04.03.2010 Peritor GmbH SimplyStored & RockingChair Ruby on CouchDB Thursday, March 4, 2010

Upload: jonathan-weiss

Post on 15-Jan-2015

3.440 views

Category:

Technology


4 download

DESCRIPTION

Presentation by Jonathan Weiss about Ruby on CouchDB at Ruby User Group Berlin in Marc 2010. Present SimplyStored, a nice wrapper for Ruby object. RockingChair is an in-memory CouchDB for speeding up your tests.

TRANSCRIPT

Page 1: Ruby on CouchDB - SimplyStored and RockingChair

Jonathan Weiss, 04.03.2010Peritor GmbH

SimplyStored & RockingChairRuby on CouchDB

Thursday, March 4, 2010

Page 2: Ruby on CouchDB - SimplyStored and RockingChair

Peritor

2

Cloud-Management und -Deployment made easy

http://scalarium.com

Thursday, March 4, 2010

Page 3: Ruby on CouchDB - SimplyStored and RockingChair

Database Requirements

High availability

Easy replication and copy

Clustering

3

Thursday, March 4, 2010

Page 4: Ruby on CouchDB - SimplyStored and RockingChair

4

CouchDBrelax

Thursday, March 4, 2010

Page 5: Ruby on CouchDB - SimplyStored and RockingChair

Die Lösung

5

Built for the Web

Scales

Performant

Replication built-in

Flexible schema

Thursday, March 4, 2010

Page 6: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

6

{ "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true}

Thursday, March 4, 2010

Page 7: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

7

{ "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true}

Thursday, March 4, 2010

Page 8: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

8

{ "_id": "BCCD12CBB", "_rev": "1-AB764C", "type": "person", "name": "Darth Vader", "age": 63, "headware": ["Helmet", "Sombrero"], "dark_side": true}

Thursday, March 4, 2010

Page 9: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB - CRUD

Create and update:

PUT /starwars/BCCD12CBB

Read:

GET /starwars/BCCD12CBB

Delete:

DELETE /starwars/BCCD12CBB

9

Thursday, March 4, 2010

Page 10: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

How do I query my data?

10

Thursday, March 4, 2010

Page 11: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

11

Views!

Thursday, March 4, 2010

Page 12: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

12

function(doc) { if (doc.headware) { for (var hat in doc.headware) { emit(hat, 1); } }}

Thursday, March 4, 2010

Page 13: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

13

function(keys, values, rereduce) { return sum(values);}

Thursday, March 4, 2010

Page 14: Ruby on CouchDB - SimplyStored and RockingChair

CouchDB

14

function(keys, values, rereduce) { return sum(values);}

Thursday, March 4, 2010

Page 15: Ruby on CouchDB - SimplyStored and RockingChair

Queries

SQL

15

SELECT * FROM

`users` WHERE

`users`.id = 5

AND `status` = 1;

CouchDB JavaScript

function(doc) {

if (doc['ruby_class'] == 'User' && doc['status'] == 1) {

emit([doc.project_id, doc.created_at], null);

}

}

Thursday, March 4, 2010

Page 16: Ruby on CouchDB - SimplyStored and RockingChair

Queries

ActiveRecord

16

SimplyStored

class Project

include SimplyStored::Couch

has_many :users

end

Project.first.users

class Project < ActiveRecord::Base

has_many :users

end

Project.first.users

Thursday, March 4, 2010

Page 17: Ruby on CouchDB - SimplyStored and RockingChair

SimplyStored

http://github.com/peritor/simply_stored17

SimplyStored

Models

Associations

Validations

Callbacks

Dynamic finder

S3 attachments

Paranoid delete

Thursday, March 4, 2010

Page 18: Ruby on CouchDB - SimplyStored and RockingChair

SimplyStored

Standing on the shoulders of giants:

- CouchPotato

- CouchRest

- RestClient

- HTTP

- CouchDB

http://github.com/peritor/simply_stored

Thursday, March 4, 2010

Page 19: Ruby on CouchDB - SimplyStored and RockingChair

RockingChair

In-memory CouchDB

- Just a big Hash

- Speeds up your tests

- Tests can run in parallel

- Nice for debugging

http://github.com/jweiss/rocking_chair

Thursday, March 4, 2010

Page 20: Ruby on CouchDB - SimplyStored and RockingChair

Now show me some Code!

Thursday, March 4, 2010

Page 21: Ruby on CouchDB - SimplyStored and RockingChair

© Peritor GmbH - Alle Rechte Vorbehalten

Peritor GmbHBlücherstr. 22, Hof III Aufgang 610961 Berlin

Tel.: +49 (0)30 69 20 09 84 0Fax: +49 (0)30 69 20 09 84 9

Internet: www.peritor.comE-Mail: [email protected]

Thursday, March 4, 2010