Skip to content

nigelr/plasmadb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOD3 - Document Oriented Database (3) within Rails

Summary

Concept build of a Documented Oriented Database within rails using active record.

For information on Documented Oriented Database - en.wikipedia.org/wiki/Document-oriented_database

A true Document Oriented database is designed to allow for dynamic schema and huge datastores. They require restful or other unique methods to deal with data. Searching for data is done view views which need to be prepared prior to the search.

This system stores all information into a relation database, it breaks up each field as it receives it and stores it into its own store. This reduces efficiency but improves searchability. When it saves each item it creates or re-uses an existing field. This allows for searching by either a field (or multiple) for a specific peaice of data).

On the roadmap is building and searching custom views (indexes).

Usage

DOD has three main methods

  • retrieve

  • store

  • search

Usage Examples

Retrieve

  • Doc.retrieve :all => retrieves all document

  • Doc.retrieve :first => retrieves first document

  • Doc.retrieve :last => retrieves last document

  • Doc.retrieve 56 => retrieves single document

  • Doc.retrieve [45, 96, 100, 4] => retrieves these documents

Store

  • Doc.store :user_name => "superman", :pasword => "letmein" => creates new document

  • Doc.store :_id => 96, :_rev => 3, :user_name => "atomicboy", :age => 12 => Updates document 96 with new values

  • Doc.search "superman" => Returns an array of document ids with exact match for “superman” in any field

  • Doc.search "superman", :fields=>:user_name => Returns an array of document ids with exact match for “superman” in field named “user_name”

  • Doc.search "superman", :fields=>[:user_name, :login_name] => Returns an array of document ids with exact match for “superman” in fields named “user_name” or “login_name”

  • Doc.search "super", :fields=>{:name=>[:first, :middle, :last]} => Returns an array of document ids with exact match for “superman” in fields named :name=>:first or :name=>:middle or :name=>:last

  • Doc.search "super", :fields=>{:name=>"*"} => Returns an array of document ids with exact match for “superman” in fields named :name=>:first or :name=>:middle or :name=>:last or any other field directly below :name

  • Doc.search "123456789", :fields=>{:phone=>{:office=>:freecall}} => Returns an array of document ids with exact match for “12345678” in field named :phone=>{:office=>:freecall}}

  • Doc.search "per", :operator => "*" => Returns an array documents which contains the letters “per” in any_field

  • Doc.search "superman", :ids => [45, 10] => Returns an array of document ids with exact match for “superman” in any field. Only searches the supplied document ids

Build Documentation

Build “rake doc:app” for documentation.

Roadmap / Features

  • Views/custom indexes

  • Turn into a plugin

Credits

  • Nigel Rausch

License

The MIT License

Copyright © 2008 Nigel Rausch

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.