Giter VIP home page Giter VIP logo

settee's Introduction

Inspired by: CouchRest library for Ruby and the couchdb-python library.

Server Functions

  1. Specify a server:
    $server = new SetteeServer('http://127.0.0.1:5984');
  2. Database API
    1. Create a database:
      $ret = $server->create_db('irakli_test');
    2. Drop a database:
      $ret = $server->drop_db('irakli_test');
    3. List all databases:
      $ret = $server->list_dbs();
    4. Get a database object
      $db = $server->get_db('irakli_test');
  3. Document API
    1. Create/Update a document:
      $ret = $db->save($doc);
    2. Retrieve a document:
      $db_doc = $db->get($id);
    3. Determine the latest revision_id for a document:
      $rev = $db->get_rev($id);
    4. Delete a document:
      $db_doc = $db->delete($doc);
  4. Attachments API
    1. Add content as attachment:
      $db->add_attachment($doc, "foo.txt", "Some text that will be base64 encoded", "text/plain");
    2. Add a file path to be attached:
      $db->add_attachment_file($doc, "foo.pdf", $file_path, "application/pdf");
    3. Add a file path to be attached (mime-type is auto-detected):
      $db->add_attachment_file($doc, "foo.pdf", $file_path);
    4. Full attachment saving example:
      $doc = new stdClass();
      $doc→id = “attachment_doc”;
      $file_path = dirname(
      _FILE__) . “/resources/couch-logo.pdf”;
      $this→db→add_attachment_file($doc, “foo.pdf”, $file_path, “application/pdf”);
      $db_doc = $this→db→save($doc);
    5. ATTENTION: there is no “load_attachments” method, because when you load a document, all its attachments get loaded with it, as well.
  5. Views API
    1. Create a new view or save a view:
      $view = $db->save_view("some_design_document_id", "a_view_name", $map_src);
      $view = $db->save_view("some_design_document_id", "a_view_name", $map_src, $reduce_src);
    2. Get a view (run query and get results):
      $view = $db->get_view("some_design_document_id", "a_view_name");
    3. Parametrized view:
      $view = $db->get_view("some_design_document_id", "a_view_name", "2009/02/17 21:13:39");
    4. Parametrized view with key range:
      $view = $db->get_view("some_design_document_id", "a_view_name", array("2009/01/30 18:04:11", "2009/02/17 21:13:39"));
    5. Parametrized view with key range, ordered descending:
      $view = $db->get_view("some_design_document_id", "a_view_name", array("2009/01/30 18:04:11", "2009/02/17 21:13:39"), true);

Requirements

  1. PHP 5.2 or newer

Recommended

  1. PHP 5.3 or newer. With PHP 5.2 following functionality will not work:
    1. Some unit-tests
    2. Mime type auto-detection.
  2. pecl_http

settee's People

Contributors

inadarei avatar abuddy avatar

Stargazers

Kamil Ciemniewski avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.