4. » N-Gram Search
https://github.com/artsy/mongoid_fulltext
class Artist
include Mongoid::Document
include Mongoid::FullTextSearch
field :first_name
field :last_name
def name
[first_name, last_name].join(' ')
end
fulltext_search_in :name
end
5. MongoDB: A Sparse Hash
{
Contemporary : 100,
Computer Art : 20,
Plays With Scale: 80,
Humor : 70,
Nostalgia : 0,
Hairy or Fluffy : 0
}
~ 50 of 850 genes
6. MongoDB: Inheritance in the Database
{ {
_type : SoloArtist, _type : ArtCollective
birthday : 1929, founded : 1929
deathday : 1972 }
}
7. MongoDB: Cartesian Product
{
id : BSON::ObjectId(…)
color : red,
medium : works-on-paper,
size : small,
price : [0, 12, 48],
}
8. MongoDB: from LSH to K-Most Similar Graph
{
artwork_id : BSON::ObjectId(…)
neighbors : [[ BSON::ObjectId(…), score ], … ]
}
http://www.mit.edu/~andoni/LSH/
http://www.cs.princeton.edu/cass/papers/www11.pdf
9.
10. class User
include Mongoid::Document
field :account_created, default: false
has_many :authentications
def account_created?
account_created || authentications.any?
end
end
task :migrate do
User.where({ :account_created.exists => false }).each do |user|
user.update_attributes!({ account_created: user.account_created? })
end
end
18. class User
include Mongoid::Document
end
class Admin < User
end
class Representative
include Mongoid::Document
belongs_to :user, inverse_of: :representative
belongs_to :admin , inverse_of: nil
end
testing models and APIs will save your life
21. Local MongoDB
sudo rm /var/lib/mongodb/mongod.lock
Heroku MongoDB small
Heroku MongoDB shared replica set
MongoHQ dedicted replica set
22. MongoHQ
mongodump
Heroku
mongodump
Heroku & Local
http://code.dblock.org/a-rake-task-for-copying-mongodb-databases
23. » $15 - $49 per developer / month
» 149$ / month for a Small Replica Set
» $1345 / month for a Large Replica Set
--------
~ 25K$ / year on database hosting