On Jul 27, 2006, at 9:45 PM, GFunk913 / gmail.com wrote:

> Jamey Cribbs wrote:
>> You can download it from:  http://rubyforge.org/projects/mongoose/
>>
>> *What's New*
>>
>> Well, there's a lot of new stuff in this release, and some old  
>> stuff put
>> back in, as well.  John Long pointed out that the use of  
>> #instance_eval
>> in the 0.2.0 release would be problematic because the query block  
>> would
>> no longer have access to instance variables from the calling object.
>> After looking at this all weekend and getting feedback from a  
>> number of
>> people, I have decided to go back to the previous query syntax  
>> whereby
>> you specify the table class as a block parameter and qualify each  
>> column
>> name with the table class name.   So, it's back to:
>>
>>     Dog.find { |dog| dog.breed == "German Shepard" }
>>
>> instead of:
>>
>>     Dog.find { breed == "German Shepard" }
>>
>> Besides this one step back, there have been a lot of steps  
>> forward.  The
>> query engine code is totally re-written, thanks to input and code  
>> ideas
>> from Logan Capaldo.  I have added a bunch of methods from  
>> ActiveRecord,
>> including dynamic finder methods like Table.find_by_user_name.
>> Additionally, I have added Table.import and Table.export methods that
>> allow you to get data in and out of a table via CSV.  So, grab the
>> latest release and let me know what you think.
>>
>> Documentation is still light, so the best way to learn is to look  
>> in the
>> "example" directory and at the unit tests.
>>
>> *What is Mongoose*
>>
>> Mongoose is a database management system written in Ruby.  It has an
>> ActiveRecord-like interface, uses Skiplists for its indexing, and
>> Marshal for its data serialization.  I named it Mongoose, because,  
>> like
>> Rudyard Kipling's Rikki-Tikki-Tavi, my aim is for it to be small,  
>> quick,
>> and friendly.
>>
>> You can find rudimentary documentation in the README file and some
>> sample scripts in the example directory.
>>
>> Jamey Cribbs
>> jcribbs / netpromi.com
>
> Got another question for you, if you don't mind sparing a couple
> minutes.  Thanks in advance for taking the time.
>
> What would be the best/easiest way to accomplish the intent of the
> following code?
>
> require 'mongoose'
>
> # Create a class for your table.
> class Thing < Mongoose::Table
> end
>
> # Create a database instance.
> db = Mongoose::Database.new
>
> # Create new table.  Notice how you specify whether a column is  
> indexed
> or not.
> db.create_table(:thing) do |tbl|
>   tbl.add_column(:foo,:dunno_what_to_put)
> end
>
> # Add a record.  You can also use #create.
> rec = Thing.new
> rec.foo = (1..100).to_a
> rec.save
>
> puts Thing.find.first.foo.size    #100
>
> # Close database.  This will write the indexes out to disk so they can
> be
> # initialized quickly next time.
> db.close
>
>

It's a (semi-)relation db. Store the array as a set of rows.

Something like:

class ArrayTable < Mongoose::Table
end

db.create_table(:array_table) do |tbl|
   tbl.add_column(:array_id, :array_position, :array_value)
end

array_id = 1

(1..100).each_with_index do |value, position|
   ArrayTable.create :array_id => array_id, :array_position => position,
     :array_value => value
end