BushDB::DB
Inherits Struct < Value < Object
A structure for database management - Set, get, has, update, delete, clear and napalm.
Example:
require "bushdb"
db = BushDB::DB.new
db.set("key name", "Some text")
db.get("key name") # => "Some text"
db.has("key name") # => true
db.delete("key name")
db.clear
db.napalm
Constructors
Instance methods
Directory permissions.
The linux-style permission mode can be specified, with a default of 777 (0o777).
Directory permissions.
The linux-style permission mode can be specified, with a default of 777 (0o777).
Remove directory of database.
If the directory is missing, an #ErrorDirMissing exception is raised.
WARNING: Be careful, this will remove all keys.
Example:
require "bushdb"
db = BushDB::DB.new
db.clear
db.clear # => DirMissing
Delete the key-value from the database.
If the key is missing, an #ErrorKeyMissing exception is raised.
Example:
require "bushdb"
db = BushDB::DB.new
db.set("key name", "Some text")
db.delete("key name")
db.get("key name") # => nil
db.delete("key name") # => KeyMissing
Get the value by key from the database.
Example:
require "bushdb"
db = BushDB::DB.new
db.set("key name", "Some text")
db.get("key name") # => "Some text"
db.get("key missing") # => nil
Check the presence of a key in the database.
Example:
require "bushdb"
db = BushDB::DB.new
db.set("key name", "Some text")
db.has?("key name") # => true
db.has?("key missing") # => false
Delete the root directory.
If the directory is missing, an #ErrorDirMissing exception is raised.
WARNING: Be careful, this will remove all databases.
NOTE: The main purpose is tests.
Example:
require "bushdb"
db = BushDB::DB.new
db.napalm
db.napalm # => DirMissing
Add or update key-value pair(s) to the database.
Example:
require "bushdb"
db = BushDB::DB.new
db.set("key name", "Some text")