# Class: Core

## Core

#### new Core()

Creates a new ForerunnerDB instance. Core instances handle the lifecycle of multiple database instances.

Source:
  - Core.js, line 27

### Methods

- (static) moduleLoaded(moduleName, callback)
- (static) moduleLoaded(moduleName, callback)
- (static) moduleLoaded(moduleName, success, failure)
- (static) moduleLoaded(moduleName) → {Boolean}
- collection()
- databases(search) → {Array}
- db(nameopt) → {Db}
- init() → {*}
- instances(indexopt) → {Array|Object}
- instantiatedCount() → {Number}
- isClient() → {Boolean}
- isServer() → {Boolean}
- namedInstances(nameopt) → {Array|Object}
- version(val, callback) → {Boolean}

#### (static) moduleLoaded(moduleName, callback)

Checks if a module is loaded and if so calls the passed callback method.

##### Parameters:

Name | Type | Description
--- | --- | ---
`moduleName` | String | The name of the module to check for.
`callback` | function | The callback method to call if module is loaded.

Source:
  - Core.js, line 117

#### (static) moduleLoaded(moduleName, callback)

Checks if an array of named modules are loaded and if so calls the passed callback method.

##### Parameters:

Name | Type | Description
--- | --- | ---
`moduleName` | Array | The array of module names to check for.
`callback` | function | The callback method to call if modules are loaded.

Source:
  - Core.js, line 142

#### (static) moduleLoaded(moduleName, success, failure)

Checks if a module is loaded and if so calls the passed success method, otherwise calls the failure method.

##### Parameters:

Name | Type | Description
--- | --- | ---
`moduleName` | String | The name of the module to check for.
`success` | function | The callback method to call if module is loaded.
`failure` | function | The callback method to call if module not loaded.

Source:
  - Core.js, line 174

#### (static) moduleLoaded(moduleName) → {Boolean}

Checks if a module has been loaded into the database.

##### Parameters:

Name | Type | Description
--- | --- | ---
`moduleName` | String | The name of the module to check for.

Source:
  - Core.js, line 91

##### Returns:

True if the module is loaded, false if not.

Type
  Boolean

#### collection()

Added to provide an error message for users who have not seen the new instantiation breaking change warning and try to get a collection directly from the core instance.

Source:
  - Core.js, line 286

#### databases(search) → {Array}

Returns an array of databases that ForerunnerDB currently has.

##### Parameters:

Name | Type | Description
--- | --- | ---
`search` | String | RegExp | The optional search string or regular expression to use to match collection names against.

Source:
  - Db.js, line 540

##### Returns:

An array of objects containing details of each database that ForerunnerDB is currently managing and it's child entities.

Type
  Array

#### db(nameopt) → {Db}

Gets a database instance by name.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | String | <optional> | Optional name of the database. If none is provided a random name is assigned.

Source:
  - Db.js, line 515

##### Returns:

Type
  Db

#### init() → {*}

Override the Core init to instantiate the plugin.

Source:
  - NodeApiServer.js, line 914

##### Returns:

Type
  *

#### instances(indexopt) → {Array|Object}

Get all instances as an array or a single ForerunnerDB instance by it's array index.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`index` | Number | <optional> | Optional index of instance to get.

Source:
  - Core.js, line 53

##### Returns:

Array of instances or a single instance.

Type
  Array | Object

#### instantiatedCount() → {Number}

Returns the number of instantiated ForerunnerDB objects.

Source:
  - Core.js, line 43

##### Returns:

The number of instantiated instances.

Type
  Number

#### isClient() → {Boolean}

Checks if the database is running on a client (browser) or a server (node.js).

Source:
  - Core.js, line 268

##### Returns:

Returns true if running on a browser.

Type
  Boolean

#### isServer() → {Boolean}

Checks if the database is running on a client (browser) or a server (node.js).

Source:
  - Core.js, line 277

##### Returns:

Returns true if running on a server.

Type
  Boolean

#### namedInstances(nameopt) → {Array|Object}

Get all instances as an array of instance names or a single ForerunnerDB instance by it's name.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`name` | String | <optional> | Optional name of instance to get.

Source:
  - Core.js, line 67

##### Returns:

Array of instance names or a single instance.

Type
  Array | Object

#### version(val, callback) → {Boolean}

Checks version against the string passed and if it matches (or partially matches) then the callback is called.

##### Parameters:

Name | Type | Description
--- | --- | ---
`val` | String | The version to check against.
`callback` | function | The callback to call if match is true.

Source:
  - Core.js, line 209

##### Returns:

Type
  Boolean