Permalink
Browse files

Added example of using object for key

  • Loading branch information...
1 parent ca2efae commit 8ec47dcc2d33ffd270a5b0d926d6479a33c5e67c @jnunemaker committed Jun 25, 2012
Showing with 19 additions and 0 deletions.
  1. +19 −0 examples/object_for_key.rb
@@ -0,0 +1,19 @@
+require 'rubygems'
+require 'pathname'
+
+root_path = Pathname(__FILE__).dirname.join('..').expand_path
+lib_path = root_path.join('lib')
+$:.unshift(lib_path)
+
+require 'adapter/mongo'
+
+key = BSON::OrderedHash['s' => 1, 'n' => 1]
+client = Mongo::Connection.new.db('adapter')['testing']
+adapter = Adapter[:mongo].new(client)
+adapter.clear
+
+adapter.write(key, :v => 1)
+
+doc = adapter.read(key)
+
+puts doc.inspect

0 comments on commit 8ec47dc

Please sign in to comment.