Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'mongo'
- uid, aid = BSON::ObjectID.new, BSON::ObjectID.new
- db = Mongo::Connection.new.db('testing')
- db.drop_collection('ratings')
- db.create_collection('ratings')
- ratings = db['ratings']
- ratings.create_index([[:user_id, Mongo::ASCENDING], [:article_id, Mongo::ASCENDING]], :unique => true)
- ratings.save({:user_id => uid, :article_id => aid}, :safe => true)
- ratings.save({:user_id => uid, :article_id => aid}, :safe => true)
Add Comment
Please, Sign In to add comment