Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
tomclose committed Aug 6, 2013
0 parents commit 45a2e0d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'
ruby '1.9.3'
gem 'mongoid'
32 changes: 32 additions & 0 deletions app.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
require 'sinatra'
require 'mongoid'
require 'json'

## Mongoid setup
## =============

Mongoid.load!("mongoid.yml", :development)

class User
include Mongoid::Document

field :name
field :email
end

## Sinatra app
## ===========

# display form
get '/' do

end

# add new user, display thanks
post '/' do

end

# show all the users so far
get '/list' do
end
26 changes: 26 additions & 0 deletions db_examples.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require 'mongoid'
require 'json'

Mongoid.load!("mongoid.yml", :development)

class User
include Mongoid::Document

field :name
field :email
end


# How many users are there currently in the database
User.count


u = User.new(:name => "Tom", :email => '[email protected]')

u.save

u1 = User.first

User.count

User.all {|u| puts u.name}
6 changes: 6 additions & 0 deletions mongoid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
development:
sessions:
default:
hosts:
- localhost:27017
database: mongo_examples

0 comments on commit 45a2e0d

Please sign in to comment.