new YMongoose()
Utility tool to manage mongoose connection and auto loading models.
Members
(private, static) crud :Boolean
Define is we create automatique crud function
Type:
- Boolean
(private, static) loaded :Boolean
Define if models are loaded
Type:
- Boolean
(private, static) loaded :Boolean
Internal modules
Type:
- Boolean
(private, static) logger :Instance
Logger instance
Type:
- Instance
(private, static) mongoose :Instance
Mongoose instance
Type:
- Instance
(private, static) paths :Object
Model Path definition to use on autoLoading
Type:
- Object
Methods
addModel(value) → {Boolean}
Create a model from given data
Parameters:
Name | Type | Description |
---|---|---|
value |
Object | data to used for creation |
Returns:
created model or false if an error occured
- Type
- Boolean
connect(url, options) → {Object}
Create a connection on mongo server
Parameters:
Name | Type | Description |
---|---|---|
url |
String | bdd url connection |
options |
Object | options for connection |
Returns:
promise status to use for connection testing
- Type
- Object
createCrud(value, exclude, redisIncludes) → {Object|Boolean}
Adding crud method to current object
Parameters:
Name | Type | Description |
---|---|---|
value |
Object | a valid schema instance to use |
exclude |
Array | method to exclude on add crud request |
redisIncludes |
Object | default redis include config retreive form model definition |
Returns:
if all is ok return new schema false otherwise
- Type
- Object | Boolean
createMethod(value, items, modelName) → {Object|Boolean}
Adding custom method to current object
Parameters:
Name | Type | Description |
---|---|---|
value |
Object | default schema to use |
items |
String | method name to retreive on validators files |
modelName |
String | model name to use for validator filter files |
Returns:
if all is ok return new schema false otherwise
- Type
- Object | Boolean
createValidator(value, validatorName, modelName) → {Object|Boolean}
Create & add a validate function on current schema for create usage
Parameters:
Name | Type | Description |
---|---|---|
value |
Object | default schema to use |
validatorName |
String | validator name to retreive on validators files |
modelName |
String | model name to use for validator filter files |
Returns:
if all is ok return new schema false otherwise
- Type
- Object | Boolean
disconnect() → {Object}
Disconnection current connection
Returns:
promise status to use for connection testing
- Type
- Object
enableElasticsearch(hosts, options) → {Boolean}
An utility method to save host config for elastic search instances
Parameters:
Name | Type | Description |
---|---|---|
hosts |
Array | list of hosts to use on elastic configuration |
options |
Object | property to set on options |
Returns:
true if all is ok false otherwise
- Type
- Boolean
enableRedis(hosts, options, cluster, defaultExpireTime) → {Object}
enable redis on current module
Parameters:
Name | Type | Description |
---|---|---|
hosts |
Array | lists of use hosts |
options |
Object | options to use on redis instance |
cluster |
Boolean | set to true if a cluster connection is needed |
defaultExpireTime |
Number | to force the default expire time for all of insertion |
Returns:
current redis instance
- Type
- Object
enums(directory) → {Boolean}
Define current enums definition path to use for mapping
Parameters:
Name | Type | Description |
---|---|---|
directory |
String | directory path to use |
Returns:
true if add was ok false otherwise
- Type
- Boolean
getModel(name, isInstance) → {Boolean|Instance}
Retreive a valid model for usage
Parameters:
Name | Type | Description |
---|---|---|
name |
String | model name wanted |
isInstance |
Boolean | true is we want an instance false otherwise |
Returns:
false if an error occured, a model object if all is ok
- Type
- Boolean | Instance
getRedis() → {Object}
Default accessor to retreive redis instance
Returns:
default redis instance
- Type
- Object
isConnected() → {Boolean}
Check is currenct connection is connected
Returns:
true if is connected false otherwise
- Type
- Boolean
isDisconnected() → {Boolean}
Check is current connection is disconnected
Returns:
true if is connected false otherwise
- Type
- Boolean
isLoaded() → {Boolean}
Get current curred loaded status
Returns:
true if all is ok false otherwise
- Type
- Boolean
isReady(showErrors) → {Boolean}
Check is current connector is ready
Parameters:
Name | Type | Description |
---|---|---|
showErrors |
Boolean | true is we want |
Returns:
true if all is ok false otherwise
- Type
- Boolean
load() → {Object}
Load models, from given path
Returns:
a valid promise
- Type
- Object
methods(directory) → {Boolean}
Define current methods path to use for mapping
Parameters:
Name | Type | Description |
---|---|---|
directory |
String | directory path to use |
Returns:
true if add was ok false otherwise
- Type
- Boolean
models(directory) → {Boolean}
Define current models path to use for mapping
Parameters:
Name | Type | Description |
---|---|---|
directory |
String | directory path to use |
Returns:
true if add was ok false otherwise
- Type
- Boolean
setPath(directory, stype) → {Boolean}
Set path of model and directory for loading
Parameters:
Name | Type | Description |
---|---|---|
directory |
String | directory path to set |
stype |
String | defined witch element we prepare to defined |
Returns:
true if all is ok false otherwise
- Type
- Boolean
validators(directory) → {Boolean}
Define current controller path to use for mapping
Parameters:
Name | Type | Description |
---|---|---|
directory |
String | directory path to use |
Returns:
true if add was ok false otherwise
- Type
- Boolean