The full, boring, unadultered enmap docs.
Kind: global class
Extends: Map
new Enmap(iterable, options)
Initializes a new Enmap, with options.
enmap.count ⇒ integer
Retrieves the number of rows in the database for this enmap, even if they aren't fetched.
Kind: instance property of
Returns: integer - The number of rows in the database.
enmap.indexes ⇒ array.
Retrieves all the indexes (keys) in the database for this enmap, even if they aren't fetched.
Kind: instance property of
Returns: array. - Array of all indexes (keys) in the enmap, cached or not.
enmap.autonum ⇒ number
Generates an automatic numerical key for inserting a new value. This is a "weak" method, it ensures the value isn't duplicated, but does not guarantee it's sequential (if a value is deleted, another can take its place). Useful for logging, but not much else.
Kind: instance property of
Returns: number - The generated key number.
Example
enmap.set(key, val, path) ⇒
Sets a value in Enmap.
Kind: instance method of
Returns: - The enmap.
Example
enmap.get(key, path) ⇒ *
Retrieves a key from the enmap. If fetchAll is false, returns a promise.
Kind: instance method of
Returns: * - The value for this key.
Example
enmap.fetchEverything() ⇒
Fetches every key from the persistent enmap and loads them into the current enmap value.
Kind: instance method of
Returns: - The enmap containing all values.
enmap.fetch(keyOrKeys) ⇒ | *
Force fetch one or more key values from the enmap. If the database has changed, that new value is used.
Kind: instance method of
Returns: | * - The Enmap, including the new fetched values, or the value in case the function argument is a single key.
enmap.evict(keyOrArrayOfKeys) ⇒
Removes a key or keys from the cache - useful when disabling autoFetch.
Kind: instance method of
Returns: - The enmap minus the evicted keys.
enmap.changed(cb)
Function called whenever data changes within Enmap after the initial load. Can be used to detect if another part of your code changed a value in enmap and react on it.
Kind: instance method of
Example
enmap.close() ⇒ Promise.
Shuts down the database. WARNING: USING THIS MAKES THE ENMAP UNUSEABLE. You should only use this method if you are closing your entire application. Note that honestly I've never had to use this, shutting down the app without a close() is fine.
Kind: instance method of
Returns: Promise. - The promise of the database closing operation.
enmap.setProp(key, path, val) ⇒
Modify the property of a value inside the enmap, if the value is an object or array. This is a shortcut to loading the key, changing the value, and setting it back.
Kind: instance method of
Returns: - The enmap.
enmap.push(key, val, path, allowDupes) ⇒
Push to an array value in Enmap.
Kind: instance method of
Returns: - The enmap.
Example
enmap.pushIn(key, path, val, allowDupes) ⇒
Push to an array element inside an Object or Array element in Enmap.
Kind: instance method of
Returns: - The enmap.
enmap.math(key, operation, operand, path) ⇒
Executes a mathematical operation on a value and saves it in the enmap.
Kind: instance method of
Returns: - The enmap.
Example
enmap.inc(key, path) ⇒
Increments a key's value or property by 1. Value must be a number, or a path to a number.
Kind: instance method of
Returns: - The enmap.
Example
enmap.dec(key, path) ⇒
Decrements a key's value or property by 1. Value must be a number, or a path to a number.
Kind: instance method of
Returns: - The enmap.
Example
enmap.getProp(key, path) ⇒ *
Returns the specific property within a stored value. If the key does not exist or the value is not an object, throws an error.
Kind: instance method of
Returns: * - The value of the property obtained.
enmap.ensure(key, defaultValue, path) ⇒ *
Returns the key's value, or the default given, ensuring that the data is there. This is a shortcut to "if enmap doesn't have key, set it, then get it" which is a very common pattern.
Kind: instance method of
Returns: * - The value from the database for the key, or the default value provided for a new key.
Example
enmap.has(key, path) ⇒ boolean
Returns whether or not the key exists in the Enmap.
Kind: instance method of
Example
enmap.hasProp(key, path) ⇒ boolean
Returns whether or not the property exists within an object or array value in enmap.
Kind: instance method of
Returns: boolean - Whether the property exists.
enmap.delete(key, path) ⇒
Deletes a key in the Enmap.
Kind: instance method of
Returns: - The enmap.
enmap.deleteProp(key, path)
Delete a property from an object or array value in Enmap.
Kind: instance method of
enmap.deleteAll()
Deletes everything from the enmap. If persistent, clears the database of all its data for this table.
Kind: instance method of
enmap.destroy() ⇒ null
Completely destroys the entire enmap. This deletes the database tables entirely. It will not affect other enmap data in the same database, however. THIS ACTION WILL DESTROY YOUR DATA AND CANNOT BE UNDONE.
Kind: instance method of
enmap.remove(key, val, path) ⇒
Remove a value in an Array or Object element in Enmap. Note that this only works for values, not keys. Complex values such as objects and arrays will not be removed this way.
Kind: instance method of
Returns: - The enmap.
enmap.removeFrom(key, path, val) ⇒
Remove a value from an Array or Object property inside an Array or Object element in Enmap. Confusing? Sure is.
Kind: instance method of
Returns: - The enmap.
enmap.array() ⇒ Array
Creates an ordered array of the values of this Enmap. The array will only be reconstructed if an item is added to or removed from the Enmap, or if you change the length of the array itself. If you don't want this caching behaviour, use Array.from(enmap.values()) instead.
Kind: instance method of
enmap.keyArray() ⇒ Array.
Creates an ordered array of the keys of this Enmap The array will only be reconstructed if an item is added to or removed from the Enmap, or if you change the length of the array itself. If you don't want this caching behaviour, use Array.from(enmap.keys()) instead.
Kind: instance method of
enmap.random([count]) ⇒ * | Array.
Obtains random value(s) from this Enmap. This relies on .
Kind: instance method of
Returns: * | Array. - The single value if count is undefined, or an array of values of count length
enmap.randomKey([count]) ⇒ * | Array.
Obtains random key(s) from this Enmap. This relies on
Kind: instance method of
Returns: * | Array. - The single key if count is undefined, or an array of keys of count length
enmap.findAll(prop, value) ⇒ Array
Searches for all items where their specified property's value is identical to the given value (item[prop] === value).
Kind: instance method of
Example
enmap.find(propOrFn, [value]) ⇒ *
Searches for a single item where its specified property's value is identical to the given value (item[prop] === value), or the given function returns a truthy value. In the latter case, this is identical to .
All Enmap used in Discord.js are mapped using their `id` property, and if you want to find by id you should use the `get` method. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get) for details.
Kind: instance method of
Example
Example
enmap.findKey(propOrFn, [value]) ⇒ string | number
Searches for the key of a single item where its specified property's value is identical to the given value (item[prop] === value), or the given function returns a truthy value. In the latter case, this is identical to .
Kind: instance method of
Example
Example
enmap.exists(prop, value) ⇒ boolean
Searches for the existence of a single item where its specified property's value is identical to the given value (item[prop] === value).
Do not use this to check for an item by its ID. Instead, use `enmap.has(id)`. See [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has) for details.
Kind: instance method of
Example
enmap.sweep(fn, [thisArg]) ⇒ number
Removes entries that satisfy the provided filter function.
Kind: instance method of
Returns: number - The number of removed entries
enmap.filter(fn, [thisArg]) ⇒
Identical to , but returns a Enmap instead of an Array.
Kind: instance method of
enmap.filterArray(fn, [thisArg]) ⇒ Array
Identical to .
Kind: instance method of
enmap.partition(fn, [thisArg]) ⇒ Array.
Partitions the collection into two collections where the first collection contains the items that passed and the second contains the items that failed.
Kind: instance method of
Example
enmap.map(fn, [thisArg]) ⇒ Array
Identical to .
Kind: instance method of
enmap.some(fn, [thisArg]) ⇒ boolean
Identical to .
Kind: instance method of
enmap.every(fn, [thisArg]) ⇒ boolean
Identical to .
Kind: instance method of
enmap.reduce(fn, [initialValue]) ⇒ *
Identical to .
Kind: instance method of
enmap.clone() ⇒
Creates an identical shallow copy of this Enmap.
Kind: instance method of
Example
enmap.concat(...enmaps) ⇒
Combines this Enmap with others into a new Enmap. None of the source Enmaps are modified.
Kind: instance method of
Example
enmap.equals(enmap) ⇒ boolean
Checks if this Enmap shares identical key-value pairings with another. This is different to checking for equality using equal-signs, because the Enmaps may be different objects, but contain the same data.
Kind: instance method of
Returns: boolean - Whether the Enmaps have identical contents
Enmap.migrate()
Migrates an Enmap from version 3 or lower to a Version 4 enmap, which is locked to sqlite backend only. This migration MUST be executed in version 3.1.4 of Enmap, along with appropriate providers. See for more details.
Kind: static method of
Enmap.multi(names, options) ⇒ Array.
Initialize multiple Enmaps easily.
Kind: static method of
Returns: Array. - An array of initialized Enmaps.
Example