Libraries
Introduction
Libraries in Dynamo are pieces of reusable code that can be used by multiple pieces of code. A library is usually created when the developer wants to create a piece of shared functionality that should be used in multiple places.
Library Overview
Library code have to be wrapped in a function which is exported using the exports
keyword.
Libraries are accessed from the processor context by accessing the library uid as a property on the libs
object in a processors context.
Libraries do not have a custom context that gives them access to some of the important Dynamo objects like EntityRepo. To make the processor context available to the library, you would need to call the library with the processor context. Example calling a library called sampleLibrary is shown below:
this.libs.sampleLibrary.call(this, args);
this
here refers to a processors context.
Library Object
Property Name | Type | Description |
---|---|---|
_id | Mongo ObjectID | MongoDB generated ID for the Library. |
uid | String | Unique Identifier for the library that is used as the library name when calling the library. |
code | String | Library code written in JavaScript. |
_code | String | Actual library code that will be executed. This code has been transformed and wrapped in try-catches. |
_references | Array | Array of strings that are the UIDs of other libraries that are being referenced in the library. |