Socket
Book a DemoInstallSign in
Socket

gom-couchdb-adapter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gom-couchdb-adapter

0.5.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

= Generic Object Mapper - CouchDB adapter

The CouchDB adapter for the Generic Object Mapper (http://github.com/phifty/gom) provides an easy way store and fetch object data to/from a CouchDB server. Object properties are mapped as well as object relations.

http://travis-ci.org/phifty/gom-couchdb-adapter.png

== Configuration

If the couchdb adapter is chosen in the storage configuration, the following configuration values should be specified.

  • host - Hostname where the CouchDB server is running on. Default is localhost.
  • port - Port where the CouchDB server is listening to. Default is 5984.
  • database - Name of the database that should be used.
  • delete_database_if_exists - Can be true or false and specifies if an existing database should be delete or not. This can be useful in your test setup. Default is false.
  • create_database_if_missing - Can be true or false and specifies if a missing database should be created or not. Default is false.

=== Example

GOM::Storage.configure { name :storage_name adapter :couchdb host "another_host" database "production_db" delete_database_if_exists false create_database_if_missing true }

== Documents

Basically one document is created in the CouchDB database for each stored object. The instance variables from the object are stored as the document's keys and values. The objects relations to other objects are stored as references to the other object's document id. So if the following object is saved ...

class Book

attr_accessor :pages
attr_accessor :author

end

class Author

attr_accessor :name

end

author = Author.new author.name = "Mr. Storyteller"

book = Book.new book.pages = 1253 book.author = GOM::Object.reference author

GOM::Storage.store book, :storage_name

... the following documents will occur in the database.

{ "_id": "book_1", "_rev": "...", "model_class": "Book", "pages": 1253, "author_id": "author_1" }

{ "_id": "author_1", "_rev": "...", "model_class": "Author", "name": "Mr. Storyteller" }

If the author would have been stored before and assigned to an id, it wouldn't be stored again.

To get back the book from the storage, simply call ...

book = GOM::Storage.fetch "storage_name:book_1"

... and an object of the class Book with same instance variable values as it had before, will be returned. Since lazy loading is supported, the author will just be fetched on the first access. So ...

author_name = book.author.name

... will invoke another fetch of the author's object.

== Views

This adapter currently supports class and map/reduce views. For documentation see http://github.com/phifty/gom.

== Development

Development has been done test-driven and the code follows at most the Clean Code paradigms. Code smells has been removed by using the reek[http://github.com/kevinrutherford/reek] code smell detector.

The project is still experimental and under development. Any bug report and contribution is welcome!

== Support

Apart from contribution, support via Flattr[http://flattr.com/thing/108997/Generic-Object-Mapper-CouchDB-adapter] is welcome.

FAQs

Package last updated on 19 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.