http://www.erlang-factory.com/conference/London2009/speakers/endafarrell
“The learning curve for
CouchDB is quite shallow”
“The only drawback is that
you may need to do a lot
of unlearning if you're well
versed in SQL”
Keys&Values
{
    "type": "passport",
    "id": "F7802033",
    "countryCode": "IND",
    "surname": "Rai",
    "givenNames": [
      ...
{
    "type": "passport",
    "id": "F7802033",
    "countryCode": "IND",
    "surname": "Rai",
    "givenNames": [
      ...
function(doc)
{
  if (doc.type == ʻpassportʼ) {
     emit(doc._id, doc);
  }
}
{
    "total_rows": 100500,
    "offset": 0,
    "rows":
   [
      {
        "id": "F7802033",
        "key": "F7802033",...
function(doc)
{
  if (doc.type == ʻpassportʼ) {
     emit(doc._id, null);
  }
}
{
    "total_rows": 100500,
    "offset": 0,
    "rows":
   [
      {
        "id": "F7802033",
        "key": "F7802033",...
?include_docs=true
...
   "rows": [{
       "id": "F7802033",
       "key": "F7802033",
       "value": null,
       "doc"...
               
?skip=100&limit=10




 ...skip...skip...   ...skip...skip...
                                         !
?startkey=foo&limit=11




     ...   ...
                 !
{
                                           "type": "comment",
                                           "post": "FFE2.....
function(doc)
{
  if (doc.type == ʻpostʼ) {               ["FFE2...",0] → {"type": "post", "title":
                      ...
?         -42 Остроумный коментарий
anonymous        {
                     "type": "comment_rating",
                    ...
function( doc )
{
  if (doc.type == ʼcomment_ratingʼ )
  {
    emit(doc.comment, doc.rating);
  }
}


function( keys, valu...
["heavy",191] → {"type": "boxer", "name": "David Deron Haye" ...}
...
["heavy",201] → {"type": "boxer", "name": "Vitaliy K...
function( doc ) {
  if (doc.type == ʼorderʼ ) {

      for(i in doc.orderLines) {
       for(j in doc.orderLines) {
      ...
Cartesian explosion
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
CodeFest 2010. Билык В. — CouchDB: от теории к практике
Upcoming SlideShare
Loading in …5
×

CodeFest 2010. Билык В. — CouchDB: от теории к практике

1,932 views

Published on

  • Be the first to comment

  • Be the first to like this

CodeFest 2010. Билык В. — CouchDB: от теории к практике

  1. 1. http://www.erlang-factory.com/conference/London2009/speakers/endafarrell
  2. 2. “The learning curve for CouchDB is quite shallow”
  3. 3. “The only drawback is that you may need to do a lot of unlearning if you're well versed in SQL”
  4. 4. Keys&Values
  5. 5. { "type": "passport", "id": "F7802033", "countryCode": "IND", "surname": "Rai", "givenNames": [ "Aishwarya" ], "sex": "F", "birthDate": "01/11/1973", "placeOfIssue": "Mumbai" }
  6. 6. { "type": "passport", "id": "F7802033", "countryCode": "IND", "surname": "Rai", "givenNames": [ "Aishwarya" ], "sex": "F", "birthDate": "01/11/1973", "placeOfIssue": "Mumbai" }
  7. 7. function(doc) { if (doc.type == ʻpassportʼ) { emit(doc._id, doc); } }
  8. 8. { "total_rows": 100500, "offset": 0, "rows": [ { "id": "F7802033", "key": "F7802033", "value": { "_id": "F7802033", "type": "passport", "countryCode": "IND", "surname": "Rai", ... } }, ...
  9. 9. function(doc) { if (doc.type == ʻpassportʼ) { emit(doc._id, null); } }
  10. 10. { "total_rows": 100500, "offset": 0, "rows": [ { "id": "F7802033", "key": "F7802033", "value": null }, ...
  11. 11. ?include_docs=true ... "rows": [{ "id": "F7802033", "key": "F7802033", "value": null, "doc": { "_id": "F7802033", "type": "passport", "countryCode": "IND", "surname": "Rai", ... } }, ...
  12. 12.      
  13. 13. ?skip=100&limit=10 ...skip...skip... ...skip...skip... !
  14. 14. ?startkey=foo&limit=11 ... ... !
  15. 15. { "type": "comment", "post": "FFE2...", { "text": "Хотелось бы "_id": "FFE2...", сходить." "type": "post", ... "title": "Умники и умницы CodeFest", } "text": "Сегодня пятница, а значит осталась всего неделя до CodeFest { в Новосибирске..." "type": "comment", ... "post": "FFE2...", } "text": "Обязательно буду!" ... }
  16. 16. function(doc) { if (doc.type == ʻpostʼ) { ["FFE2...",0] → {"type": "post", "title": "Умники и умницы CodeFest" ...} emit([doc._id,0], null); ["FFE2...",1] → {"type": "comment", } else if (doc.type == ʼcommentʼ) { "text": "Хотелось бы сходить."...} emit([doc.post,1], null); ["FFE2...",1] → {"type": "comment", "text": "Обязательно буду!"...} } }
  17. 17. ? -42 Остроумный коментарий anonymous { "type": "comment_rating", "comment": "ABE2...", "rating": -1 ... }
  18. 18. function( doc ) { if (doc.type == ʼcomment_ratingʼ ) { emit(doc.comment, doc.rating); } } function( keys, values ) { return sum(values); }
  19. 19. ["heavy",191] → {"type": "boxer", "name": "David Deron Haye" ...} ... ["heavy",201] → {"type": "boxer", "name": "Vitaliy Klychko" ...} ... ["heavy",213] → {"type": "boxer", "name": "Nikolai Valuev" ...} GQL: SELECT * FROM Person WHERE birth_year >= :min_year AND height >= :min_height #ERROR
  20. 20. function( doc ) { if (doc.type == ʼorderʼ ) { for(i in doc.orderLines) { for(j in doc.orderLines) { if ( i != j ) { emit( [ doc.orderLines[i].article , doc.orderLines[j].article ] , 1); } ... ...
  21. 21. Cartesian explosion

×