miner
A standalone SQL ORM library for Crystal
IMPORTANT: This library is still under heavy development, and is far from ready for use in your Crystal projects.
Todo List
- [x] Query Builder
- [ ] Execute Queries
- [ ] Models
- [ ] Collections
- [ ] Auto-discovery of relationships
- [ ] Auto-casting of field values based on column type
Installation
Add this to your application's shard.yml
:
dependencies:
miner:
github: molovo/miner
Usage
require "miner"
# Create a config object
config = Miner::Config.new({
"name" => "my_database",
"username" => "foo",
"password" => "bar"
})
# Set the default database
Miner.set_default_database Miner::Database.new(config)
# Create a query
query = Miner::Query.new("countries")
.select("name", "population")
.join("city")
.select({"name", "capital"})
.on("id", "=", "parent.capital")
# Fetch the results
countries = query.fetch # => Miner::Collection
# Output the result set as JSON
puts countries.to_json
Development
TODO Write development instructions here
Contributing
- Fork it ( https://github.com/[your-github-name]/miner/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- [your-github-name] James Dinsdale - creator, maintainer