Members
ApiHealthCheck :Endpoint
Represents a controller endpoint for to check if the API is connected and working properly.
Type:
- Source:
AuthLogin :Endpoint
Represents a controller endpoint for authenticate an user.
Type:
- Source:
AuthRegister :Endpoint
Represents a controller endpoint for register an user.
Type:
- Source:
CollectionCreate :Endpoint
Represents a controller endpoint for creating a document in a collection.
Type:
- Source:
CollectionDelete :Endpoint
Represents a controller endpoint for deleting a document in a collection.
Type:
- Source:
CollectionGetDoc :Endpoint
Represents a controller endpoint for getting a document in a collection.
Type:
- Source:
CollectionGetQuery :Endpoint
Represents a controller endpoint for listing documents in a collection.
Type:
CollectionUpdateDocument :Endpoint
Represents a controller endpoint for updating a document in a collection.
Type:
Log - To log errors and any other log.
- Source:
Resource - Resource instance to call text and other resources.
- Source:
ajax - Does AJAX requests
- Source:
(constant) defaultRules :Object
Default validation rules for the Component class.
Type:
- Object
- Source:
(constant) navDefaultQuestions :Object
Default navigation questions for the ViewNavigator class.
Type:
- Object
- Source:
toolsCLI - CLI tools to use in everywhere.
- Source:
Methods
#getPath(path) → {*}
Method that that safely gets the values of an object property without throw errors bay an undefined path.
Parameters:
| Name | Type | Description |
|---|---|---|
path |
string | array.<string> | Can be a string path for the object property with each property separated by a ".", or can be an array of string where each string is a path. |
- Source:
Returns:
- Anything that can be stored on the provided path
- Type
- *
build(value) → {ValidationBase}
Factory function to create a ValidationBase instance for a specific value.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
* | The value to be validated. |
- Source:
Returns:
- A ValidationBase instance for the provided value.
- Type
- ValidationBase
convertMillisTo(value, unit) → {number}
Converts a numeric value from milliseconds to a specific time unit.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | The numeric value to be converted (in milliseconds). |
unit |
string | The desired time unit of the output value (minute, hour, day, week, month, year). |
- Source:
Throws:
-
- Throws an error if the input value or unit is invalid.
- Type
- Error
Returns:
- The converted value in the specified time unit.
- Type
- number
convertToMillis(value, unit) → {number}
Converts a numeric value from a specific time unit to milliseconds.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
number | The numeric value to be converted. |
unit |
string | The time unit of the input value (minute, hour, day, week, month, year). |
- Source:
Throws:
-
- Throws an error if the input value or unit is invalid.
- Type
- Error
Returns:
- The converted value in milliseconds.
- Type
- number
(async) create(collectionName, data, optionsopt) → {Promise.<Object>}
Creates a new document in the specified collection.
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
collectionName |
string | The name of the collection to create the document in. |
|||||||||
data |
Object | The data to be added to the document. |
|||||||||
options |
Object |
<optional> |
Additional options for document creation. Properties
|
- Source:
Throws:
-
If an error occurs during document creation.
- Type
- Error.Log
Returns:
The created document or a draft object, if specified.
- Type
- Promise.<Object>
(async) createCounter(collection)
Creates a counter document for a specific collection if it does not already exist.
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
Object | The collection object containing 'name' and 'symbol' properties. |
- Source:
Throws:
-
- Throws an error if there is an issue creating the counter document.
- Type
- Error
(async) createUserCLISession(user) → {Object}
Creates or updates a user's session in the command-line interface (CLI) environment.
Parameters:
| Name | Type | Description |
|---|---|---|
user |
Object | The user object containing session-related information. |
- Source:
Throws:
-
- Throws an error if there is an issue creating or updating the user's session.
- Type
- Error
Returns:
- An object indicating the success or failure of the session creation/update process.
- Type
- Object
(async) del(setup) → {Promise.<Object>}
Deletes documents from the specified collection based on the provided filter and delete type.
Parameters:
| Name | Type | Description | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object | The delete setup object. Properties
|
- Source:
Throws:
-
If an error occurs during document deletion.
- Type
- Error.Log
Returns:
The delete result.
- Type
- Promise.<Object>
(async) end() → {Promise}
Calls the end event and goes back to the current question.
- Source:
Throws:
Throws an error if an error occurs when calling the end event.
Returns:
- Type
- Promise
findRelFields(schema, exclude, levels, currentLevel) → {Array}
Finds and returns fields in a Mongoose schema that are references to other schemas.
Parameters:
| Name | Type | Description |
|---|---|---|
schema |
Object | The Mongoose schema object to search for related fields. |
exclude |
Array | An array of field names to exclude from the result. |
levels |
number | The number of levels to search for related fields (default is 1). |
currentLevel |
number | The current level of recursion (default is 1). |
- Source:
Throws:
-
- Throws an error if there is an issue analyzing the schema.
- Type
- Error
Returns:
- An array of objects representing related fields and their respective schemas.
- Type
- Array
getCollectionModel(collection) → {Model}
Retrieves the Mongoose model for a given collection name.
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
string | The name of the collection to retrieve the model for. |
- Source:
Throws:
-
- Throws an error if the collection does not exist.
- Type
- Error
Returns:
- The Mongoose model for the specified collection.
- Type
- Model
getDoc(setup) → {Object|null}
Retrieves a single document from the specified collection based on the provided filter.
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object | The setup object for retrieving the document. Properties
|
- Source:
Throws:
-
If the specified collection schema is not found or an error occurs during document retrieval.
- Type
- Error.Log
Returns:
The retrieved document or null if no document is found.
- Type
- Object | null
getObjectPath(obj, path) → {*}
Retrieves a value from a nested object based on the specified object path.
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Object | The object to extract the value from. |
path |
string | Array | The path to the desired property. Can be a string with dot notation or an array of keys. |
- Source:
Throws:
-
- Throws an error if there is an issue accessing the object path.
- Type
- Error
Returns:
- The value at the specified object path or undefined if the path does not exist.
- Type
- *
getSessionCurrentUser() → {string|undefined}
Retrieves the current user ID from the CLI session.
- Source:
Throws:
-
- Throws an error if there is an issue retrieving the current user ID.
- Type
- Error
Returns:
- The ID of the current user if available, undefined otherwise.
- Type
- string | undefined
getUpdateProps() → {Object}
Extracts the update properties from the current update operation object.
- Source:
Returns:
- An object containing the update properties to be applied to the document.
- Type
- Object
(async) increaseCounter(collection) → {Object}
Increases the counter value for a specific collection and returns the updated counter object.
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
string | The name of the collection to increase the counter for. |
- Source:
Throws:
-
- Throws an error if there is an issue increasing the counter.
- Type
- Error
Returns:
- The updated counter object.
- Type
- Object
(async) increaseDocProp(collectionName, filter, data) → {Object}
Increases specified properties of a document based on the provided filter and data object.
Parameters:
| Name | Type | Description |
|---|---|---|
collectionName |
string | The name of the collection to update the document in. |
filter |
Object | The filter object to match the document. |
data |
Object | The data object containing properties to be incremented. |
- Source:
Throws:
-
- Throws an error if there is an issue updating the document properties.
- Type
- Error
Returns:
- The updated document object.
- Type
- Object
(async) increaseLog(logUID) → {Object}
Increases the 'groupedLogs' property of a specific log document and returns the updated log object.
Parameters:
| Name | Type | Description |
|---|---|---|
logUID |
string | The unique identifier of the log document to increase the property for. |
- Source:
Throws:
-
- Throws an error if there is an issue increasing the log property.
- Type
- Error
Returns:
- The updated log object.
- Type
- Object
(async) initialize(populate) → {Array|Object}
Initializes query results by converting MongoDB documents to objects.
Parameters:
| Name | Type | Description |
|---|---|---|
populate |
boolean | Flag indicating whether to populate related fields in the documents. |
- Source:
Throws:
-
- Throws an error if there is an issue initializing the documents.
- Type
- Error
Returns:
- An array of initialized objects or a single initialized object representing the query results.
- Type
- Array | Object
(async) isAuthenticated(token) → {boolean}
Checks if the provided token corresponds to an active authenticated session.
Parameters:
| Name | Type | Description |
|---|---|---|
token |
string | The token to be authenticated. |
- Source:
Throws:
-
- Throws an error if there is an issue with the authentication process.
- Type
- Error
Returns:
- True if the token is valid and corresponds to an active session, false otherwise.
- Type
- boolean
isCollectionExist(collection) → {string|undefined}
Checks if a collection exists in the MongoDB database.
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
string | The name of the collection to check. |
- Source:
Throws:
-
- Throws an error if there is an issue accessing the database.
- Type
- Error
Returns:
- The name of the existing collection or undefined if the collection does not exist.
- Type
- string | undefined
isDocExist(collectionName, filter) → {Promise.<boolean>}
Checks if a document exists in a specific collection based on the provided filter.
Parameters:
| Name | Type | Description |
|---|---|---|
collectionName |
string | The name of the collection to check. |
filter |
Object | The filter object to search for the document. |
- Source:
Throws:
-
- Throws an error if there is an issue accessing the database.
- Type
- Error
Returns:
- A promise that resolves to true if the document exists, false otherwise.
- Type
- Promise.<boolean>
isObjectID(value) → {boolean}
Checks if the provided value is an ObjectId or an array of ObjectIds.
Parameters:
| Name | Type | Description |
|---|---|---|
value |
Array | Object | The value to be checked. |
Returns:
- True if the value is an ObjectId or an array of ObjectIds, false otherwise.
- Type
- boolean
oid() → {boolean}
Method that evaluate if the provided object on "Object(objectToEval)" is a mongoose ObjectID or not.
- Source:
Returns:
- Type
- boolean
(async) onCreate() → {Array}
Handles relational updates when a new document is created.
Throws:
-
- Throws an error if there is an issue handling the updates.
- Type
- Error
Returns:
- An array of updated documents after the relational updates.
- Type
- Array
(async) onDelete() → {Array}
Handles relational updates when a document is deleted.
Throws:
-
- Throws an error if there is an issue handling the updates.
- Type
- Error
Returns:
- An array of updated documents after the relational updates.
- Type
- Array
(async) onUpdate() → {Array}
Handles relational updates when an existing document is updated.
Throws:
-
- Throws an error if there is an issue handling the updates.
- Type
- Error
Returns:
- An array of updated documents after the relational updates.
- Type
- Array
(async) overrideListener() → {Promise}
Override a listerner on the PoolForm.
- Source:
Throws:
Throws an error if an error occurs.
Returns:
- Type
- Promise
paginate(options) → {Object}
Paginates query results based on the provided options.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Pagination options including 'views', 'page', and 'seeMore'. |
- Source:
Throws:
-
- Throws an error if there is an issue with the pagination query.
- Type
- Error
Returns:
- The updated query object with pagination applied.
- Type
- Object
pickQueryType(filter, type) → {string}
Determines the type of query based on the provided filter and the desired query type.
Parameters:
| Name | Type | Description |
|---|---|---|
filter |
* | The filter object to analyze. |
type |
string | The desired query type ('one' for single document, 'many' for multiple documents). |
- Source:
Returns:
- The determined query type ('one' or 'many').
- Type
- string
populateAll(options) → {Object}
Populates all specified relational fields in the query results.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Population options including 'select', 'exclude', and 'levels'. |
- Source:
Throws:
-
- Throws an error if there is an issue populating relational fields.
- Type
- Error
Returns:
- The updated query object with relational fields populated.
- Type
- Object
(async) postDelete()
Middleware function executed after deleting a document. Does not perform any specific action.
- Source:
Throws:
-
- Throws an error if there is an issue handling the post-delete process.
- Type
- Error
(async) postSave()
Middleware function executed after saving a document. Handles relational updates and emits a create event for the collection.
- Source:
Throws:
-
- Throws an error if there is an issue handling relationships or emitting events.
- Type
- Error
(async) postUpdateOne()
Middleware function executed after updating a single document. Emits events based on the updated document's status and filter.
- Source:
Throws:
-
- Throws an error if there is an issue emitting events.
- Type
- Error
(async) preDelete(next)
Middleware function executed before deleting a document. Handles relational updates.
Parameters:
| Name | Type | Description |
|---|---|---|
next |
function | The function to be called to proceed to the next middleware in the stack. |
- Source:
Throws:
-
- Throws an error if there is an issue handling relationships.
- Type
- Error
(async) preSave(next)
Middleware function executed before saving a document. Increments the counter for the current collection and sets index and cod fields.
Parameters:
| Name | Type | Description |
|---|---|---|
next |
function | The function to be called to proceed to the next middleware in the stack. |
- Source:
Throws:
-
- Throws an error if there is an issue incrementing the counter or setting fields.
- Type
- Error
(async) preUpdateOne(next)
Middleware function executed before updating a single document. Updates the modifiedAt timestamp and handles relational updates.
Parameters:
| Name | Type | Description |
|---|---|---|
next |
function | The function to be called to proceed to the next middleware in the stack. |
- Source:
Throws:
-
- Throws an error if there is an issue updating the document or handling relationships.
- Type
- Error
query(setup) → {Query}
Performs a query on the specified collection based on the provided filter and sort options.
Parameters:
| Name | Type | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object | The query setup object. Properties
|
- Source:
Throws:
-
If the specified collection schema is not found or an error occurs during querying.
- Type
- Error.Log
Returns:
The query result.
- Type
- Query
(async) readable(options) → {Array}
A function to make query results readable by converting MongoDB documents to plain JavaScript objects.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Object | Additional options for query results (not used in the function). |
- Source:
Throws:
-
- Throws an error if there is an issue converting the documents.
- Type
- Error
Returns:
- An array of plain JavaScript objects representing the query results.
- Type
- Array
(async) repeat() → {Promise}
Calls the repeat event and goes back to the current question.
- Source:
Throws:
Throws an error if an error occurs when calling the repeat event.
Returns:
A promise that resolves with the result of calling goTo(this.current.id).
- Type
- Promise
(async) setListener(eventName) → {void}
Sets a new listener for the provided address
Parameters:
| Name | Type | Description |
|---|---|---|
eventName |
string | Name of the event. |
- Source:
Returns:
- Return nothing.
- Type
- void
Example
-> `setListener('onTrigger', () => takeAnAction())`
treatFilter(filter) → {Object}
Validates and transforms a filter object to a format suitable for querying the database.
Parameters:
| Name | Type | Description |
|---|---|---|
filter |
string | Object | The filter to be validated and transformed. |
- Source:
Throws:
-
- Throws an error if the filter is invalid.
- Type
- Error
Returns:
- The transformed filter object suitable for database queries.
- Type
- Object
(async) update(setup) → {Promise.<(Object|Array.<Object>)>}
Updates documents in the specified collection based on the provided filter and update data.
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setup |
Object | The update setup object. Properties
|
- Source:
Throws:
-
If an error occurs during document update.
- Type
- Error.Log
Returns:
The updated document(s) or success status, based on the update type and options.
- Type
- Promise.<(Object|Array.<Object>)>