We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6b9ab51 + c878c36 commit d4a2de5Copy full SHA for d4a2de5
databases/mongo.md
@@ -40,7 +40,8 @@ your Mongo instance.
40
41
```ruby
42
get '/collections/?' do
43
- settings.mongo_db.collection_names
+ content_type :json
44
+ settings.mongo_db.collection_names.to_json
45
end
46
47
helpers do
@@ -117,9 +118,14 @@ end
117
118
# delete the specified document and return success
119
delete '/remove/:id' do
120
content_type :json
- settings.mongo_db['test'].
121
- remove(:_id => object_id(params[:id]))
122
- {:success => true}.to_json
+ db = settings.mongo_db['test']
+ id = object_id(params[:id])
123
+ if db.find_one(id)
124
+ db.remove(:_id => id)
125
+ {:success => true}.to_json
126
+ else
127
+ {:success => false}.to_json
128
+ end
129
130
```
131
0 commit comments