-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 45a2e0d
Showing
4 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
ruby '1.9.3' | ||
gem 'mongoid' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
development: | ||
sessions: | ||
default: | ||
hosts: | ||
- localhost:27017 | ||
database: mongo_examples |