Skip to content

Instantly share code, notes, and snippets.

@johnnygoodman
Created August 27, 2010 13:29
Show Gist options
  • Save johnnygoodman/553345 to your computer and use it in GitHub Desktop.
Save johnnygoodman/553345 to your computer and use it in GitHub Desktop.
class Expense
include MongoMapper::Document
key :expense_id. ObjectId
key :amount, Integer
key :date, Date
key :notes, String
key :tags, Array
key :category, Array
end
MongoMapper.database = 'expense'
Expense.collection.remove
Expense.create(:amount => '25.00',
:date => Time.parse('08/26/2010'),
:notes => 'An Expense',
:tags => %w[Company1 Company 2],
:category => %w[Freight Web Hosting])
@jnunemaker
Copy link

I would avoid using Date. Just use Time. Date's are not native to mongo but times are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment