https://github.com/coding-cactus/easyrubydb
Simple ruby database made using https://s1.kognise.dev
https://github.com/coding-cactus/easyrubydb
Last synced: 23 days ago
JSON representation
Simple ruby database made using https://s1.kognise.dev
- Host: GitHub
- URL: https://github.com/coding-cactus/easyrubydb
- Owner: Coding-Cactus
- Created: 2021-02-21T12:45:20.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-02-21T13:42:51.000Z (over 4 years ago)
- Last Synced: 2025-02-17T14:12:59.785Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# easyrubydb
Simple ruby database made using https://s1.kognise.dev### Gemfile
```
gem 'http'
gem 'json'
gem 'easyrubydb', '~> 0.0.1'
```### Install
`gem install easyrubydb`## Usage
Firstly get a token from https://s1.kognise.dev/token
Then you need to
```ruby
require 'easyrubydb'
```Next you do
```ruby
db = DB.new(name, token)
```Where `name` is the name of your database, and `token` is the token that you got from https://s1.kognise.dev/token
Now basically all it is, is a hash that saves.
When you edit a key like this:
```ruby
db["key"] = "value"
```
It will save automatically, however if you are edditing a nested data structire like this:
```ruby
db["hash"]["key"] = "value"
```
You will have to manually call `#save` on the db. Like so:
```ruby
db["hash"]["key"] = "value"
db.save
```If you wish to iterate of the the base keys in the db, you will have to do:
```ruby
db.data.each { |key, value| puts "#{key} is #{value}" }
```Otherwise, you can just do:
```ruby
db["hash"].each { |key, value| puts "#{key} is #{value}" }
```