@@ -1,7 +1,7 @@
## 1.6.0 [unreleased]
-- Added support for MongoDB
-- Added support for Elasticsearch
+- Added support for MongoDB [beta]
+- Added support for Elasticsearch [beta]
- Fixed deprecation warning in Rails 5
## 1.5.1
@@ -355,15 +355,48 @@ data_sources:
- Oracle
- IBM DB2 and Informix
- SQLite
+- MongoDB [beta]
+- Elasticsearch [beta]
You can also create an adapter for any other data store.
+**Note:** In the examples below, we recommend using environment variables for urls.
+
+```yml
+data_sources:
+ my_source:
+ url: <%= ENV["BLAZER_MY_SOURCE_URL"] %>
+```
### Redshift
Add [activerecord4-redshift-adapter](https://github.com/aamine/activerecord4-redshift-adapter) to your Gemfile and set:
-```ruby
-ENV["BLAZER_DATABASE_URL"] = "redshift://user:password@hostname:5439/database"
+ url: redshift://user:password@hostname:5439/database
+### MongoDB
+Add [mongo](https://github.com/mongodb/mongo-ruby-driver) to your Gemfile and set:
+ url: mongodb://user:password@hostname:27017/database
+### Elasticsearch
+Add [elasticsearch](https://github.com/elastic/elasticsearch-ruby) to your Gemfile and set:
+ adapter: elasticsearch
+ url: http://user:password@hostname:9200/
```
## Learn SQL
@@ -30,7 +30,7 @@ module Blazer
end
def adapter
- settings["adapter"] || "sql"
+ settings["adapter"] || detect_adapter
def name
@@ -176,5 +176,13 @@ module Blazer
Blazer::Result.new(self, columns, rows, error, nil, cache && !cache_data.nil?)
+ def detect_adapter
+ if settings["url"].to_s.start_with?("mongodb://")
+ "mongodb"
+ else
+ "sql"
+ end