NPM module - izara-shared: Difference between revisions

From Izara Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 66: Line 66:


# return ''vertexId'' + '_CreatedBy'
# return ''vertexId'' + '_CreatedBy'
== neptuneGraphSharedLib.createVersionedVertexEdge ==
<syntaxhighlight lang="JavaScript">
/**
* Creates an edge linking a subjectVertex to it's new versioned data vertex, and updates the old current vertex's To timestamp
* @param {string} graphServiceName
* @param {string} subjectVertexId
* @param {string} newVersionedDataVertexId
* @param {string} edgeLabel
*
*/
</syntaxhighlight>
# const ''timestamp'' = current timestamp
# send request (async) to ''graphServiceName'' > [[2021-02-16 - Graph Handler - Functions#CreateEdge]]
## subjectVertexId: ''subjectVertexId''
## edgeLabel: ''edgeLabel''
## edgeId: ''subjectVertexId'' + '_' + ''edgeLabel'' + '_' + ''newVersionedDataVertexId''
## objectId: ''userVertexId''
## edgeProperties:


== neptuneGraphSharedLib.getVerticesByLabel ==
== neptuneGraphSharedLib.getVerticesByLabel ==

Revision as of 09:25, 3 March 2021

Overview

Shared libraries

Repository

https://bitbucket.org/stb_working/izara-shared/src/master/

dynamodbSharedLib

Helper functions for interacting with DynamoDB resources.

dynamodbSharedLib.createStringSet

/**
 * Creates a string set element for use with documentClient
 * @param {string[]} stringSet
 *
 * @returns {string} String formatted as a string set for Dynamo
 */

configSharedLib

Helper functions for Config tables.

configSharedLib.getConfigValue

/**
 * @param {string} configTag
 * @param {string} configKey
 *
 * @returns {Object} returns the configValue for a single config record, or null if none found
 */

neptuneGraphSharedLib

Helper functions for interacting with Neptune graph databases from any service.

neptuneGraphSharedLib.createVertexId

/**
 * Creates vertexId from vertexTag and unique id
 * @param {string} vertexTag - is the type of object
 * @param {string} uniqueId
 *
 * @returns {string} vertexId
 */
  1. Concatenate vertexTag + "_" + uniqueId

neptuneGraphSharedLib.createCreatedByEdgeId

/**
 * @param {string} vertexId
 *
 * @returns {string} createdByEdgeId
 */
  1. return vertexId + '_CreatedBy'

neptuneGraphSharedLib.createVersionedVertexEdge

/**
 * Creates an edge linking a subjectVertex to it's new versioned data vertex, and updates the old current vertex's To timestamp
 * @param {string} graphServiceName
 * @param {string} subjectVertexId
 * @param {string} newVersionedDataVertexId
 * @param {string} edgeLabel
 *
 */
  1. const timestamp = current timestamp
  2. send request (async) to graphServiceName > 2021-02-16 - Graph Handler - Functions#CreateEdge
    1. subjectVertexId: subjectVertexId
    2. edgeLabel: edgeLabel
    3. edgeId: subjectVertexId + '_' + edgeLabel + '_' + newVersionedDataVertexId
    4. objectId: userVertexId
    5. edgeProperties:

neptuneGraphSharedLib.getVerticesByLabel

/**
 * Returns all vertices that match the vertex label for the given graph
 * @param {string} graphServiceName
 * @param {string} vertexLabel
 *
 * @returns {string} vertexId
 */
  1. ..

neptuneGraphSharedLib.getVertexById

/**
 * Returns all vertices that match the vertex label for the given graph
 * @param {string} graphServiceName
 * @param {string} vertexId
 *
 * @returns {string} vertexId
 */
  1. ..