Skip to content

Commit 2ed6352

Browse files
author
Seiichi Yonezawa
committed
Rid off duplicated to_json #72
1 parent 5796373 commit 2ed6352

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

databases/mongo.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ end
7070
# find a document by its ID
7171
get '/document/:id/?' do
7272
content_type :json
73-
document_by_id(params[:id]).to_json
73+
document_by_id(params[:id])
7474
end
7575
```
7676

@@ -82,7 +82,7 @@ end
8282
post '/new_document/?' do
8383
content_type :json
8484
new_id = settings.mongo_db['test'].insert params
85-
document_by_id(new_id).to_json
85+
document_by_id(new_id)
8686
end
8787
```
8888

@@ -95,7 +95,7 @@ put '/update/:id/?' do
9595
content_type :json
9696
id = object_id(params[:id])
9797
settings.mongo_db['test'].update({:_id => id}, params)
98-
document_by_id(id).to_json
98+
document_by_id(id)
9999
end
100100

101101
# update the document specified by :id, setting just its
@@ -106,8 +106,8 @@ put '/update_name/:id/?' do
106106
id = object_id(params[:id])
107107
name = params[:name]
108108
settings.mongo_db['test'].
109-
update(:_id => id, {"$set" => {:name => name}})
110-
document_by_id(id).to_json
109+
update({:_id => id}, {"$set" => {:name => name}})
110+
document_by_id(id)
111111
end
112112
```
113113

0 commit comments

Comments
 (0)