Documentation
Last updated
Was this helpful?
Last updated
Was this helpful?
.all()
⇒Gets all the elements from the database.
Returns: All the elements in the database.
.clear()
⇒<
>
Clears all elements from the database.
Returns: <
>
— Returns undefined
.delete(key)
⇒Deletes an element from the database by key.
Parameters
key
: |
<
>
Required*
The key(s) of the element to remove from the database.
Returns: — true
if the element(s) is deleted successfully, otherwise false
.
Ensures if an element exists in the database. If the element does not exist, sets the element to the database and returns the value.
Parameters
Required*
The key of the element to ensure.
value
: *
Required*
The value of the element to ensure.
Default: null
Example
Parameters
Required*
The function to execute on each value in the element.
thisArg
: *
Default: undefined
Object to use as this
inside callback.
Example
Gets the value of an element from the database by key.
Parameters
Required*
The key of the element to get.
Default: null
The path of the property to get from the value.
Example
Checks whether an element exists in the database or not.
Parameters
Required*
The key of an element to check for.
Default: null
The path of the property to check.
.keys()
⇒Returns an array that contains the keys of each element.
Returns: — An array that contains the keys of each element.
.math(key, operation, operand, path=null)
⇒true
Performs a mathematical operation on a value of an element.
Parameters
Required*
The key of the element.
Required*
The mathematical operation to perform.
Required*
The right-hand operand.
Default: null
The path of the property to perform mathematical operation on.
Returns: true
Example
Creates multiple instances of Dreamy-db.
Parameters
Required*
An array of strings. Each element will create new instance.
Default: DreamyOptions
The options for the instances.
Example
The options the database was instantiated with.
Pushes an item to the array value in the database.
Parameters
Required*
The key of the element to push to.
value
: *
Required*
The value to push.
Default: null
The path of the property of the value to push.
Default: false
Whether or not, allow duplicates elements in the value.
Removes an item from the array value of an element in the database.
structured or complex data types such as arrays or objects cannot be removed from the value of the element.
Parameters
Required*
The key of the element to remove.
value
: *
Required*
The value to remove. Must be a string.
Default: null
The path of the property to remove.
Sets an element to the database.
Parameters
Required*
The key of the element to set to the database.
value
: *
Required*
The value of the element to set to the database.
Default: null
The path of the property to set in the value.
Example
.values()
⇒Returns an array that contains the values of each element.
Returns: — Array that contains the values of each element.
key
:
path
:
Returns: <any |
>
— The (default) value of the element.
Finds a single item where the given function returns a truthy value. Behaves
The database elements is mapped by their key
.
If you want to find an element by key, you should use the get
method instead.
See for more details.
fn
:
Returns: <*|
>
— The first element in the database that satisfies the provided testing function. Otherwise undefined
is returned
key
:
path
:
Returns: <*|
>
— The value of the element, or undefined
if the element cannot be found in the database.
key
:
path
:
Returns: <
>
— true
if the element exists in the database, otherwise false
.
key
:
operation
:
operand
:
path
:
names
: <
>
options
:
Returns: — An object containing created Dreamy-db instances.
key
:
path
:
allowDuplicates
:
Returns: <*>
— The value to push.
key
:
path
:
Returns: <*>
— The value to remove.
key
:
path
:
Returns: <true>
— Returns true
.