struct BushDB::DB
- BushDB::DB
- Struct
- Value
- Object
Overview
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
Defined in:
bushdb/db.crConstructors
Instance Method Summary
-
#branch_mode : Int32
Directory permissions.
-
#branch_mode=(branch_mode : Int32)
Directory permissions.
-
#clear : Nil
Remove directory of database.
-
#db_name : String
Database name.
-
#db_name=(db_name : String)
Database name.
-
#delete(key : String) : Nil
Delete the key-value from the database.
-
#get(key : String) : String | Nil
Get the value by key from the database.
-
#has?(key : String) : Bool
Check the presence of a key in the database.
- #initialize
-
#leaf_mode : File::Permissions
File permissions.
-
#leaf_mode=(leaf_mode : File::Permissions)
File permissions.
-
#napalm : Nil
Delete the root directory.
-
#root_store : Path
Root directory for databases.
-
#root_store=(root_store : Path)
Root directory for databases.
-
#set(key : String, value : String) : Nil
Add or update key-value pair(s) to the database.
Constructor Detail
Instance Method Detail
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")