https://github.com/njaneambrose/hoaxdb
Experimental implementation of a NoSQL database in ruby
https://github.com/njaneambrose/hoaxdb
database nosql ruby
Last synced: 2 months ago
JSON representation
Experimental implementation of a NoSQL database in ruby
- Host: GitHub
- URL: https://github.com/njaneambrose/hoaxdb
- Owner: njaneambrose
- License: mit
- Created: 2018-12-19T18:22:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-18T12:17:34.000Z (about 7 years ago)
- Last Synced: 2025-10-19T03:28:13.427Z (8 months ago)
- Topics: database, nosql, ruby
- Language: Ruby
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Hoaxdb
Hoaxdb is a simple implementation of a database written in 100% pure ruby. It offers an interface to insert,update,query and delete records like any other databse but does not offer complex features of a database. You set specific data types for your fields and you can also have default values on top of that it validates the records you enter. In terms of queries you can choose specific fields, limits and also sort according to a specific field which can be ascending or descending. Queries are written using ruby hence no external knowledge is needed.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'hoaxdb'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install hoaxdb
## Usage
Using the hoaxdb is very simple once you have installed it, the following are the basics:
#### Creating a table
```ruby
require 'hoaxdb'
db = Hoaxdb.new('products.db') #This reads an existing database or creates a database
db.create_table("products",{
"name"=>{"type"=>"String","default"=>""}, #setting default prevents nil values
"price"=>{"type"=>"Float","default"=>0.0}
})
products = db.table("products") # connect to this table
```
#### Inserting a record
```ruby
products.insert({"name"=>"Iphone","price"=>100.67}) #insert a record
```
#### Updating a record
```ruby
products.update('this["name"].eql? "Iphone"',{"quantity"=>200})
```
#### Selecting records
```ruby
products.select_if('this["name"].eql? "Iphone"')
```
#### Deleting records
```ruby
products.del_if('this["name"].eql? "Iphone"')
```
More information is available via rdoc when the gem is installed
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/njaneambrose/hoaxdb.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).