ramda#join JavaScript Examples

The following examples show how to use ramda#join. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.js    From cross-chain-realitio-proxy with MIT License 6 votes vote down vote up
export function buildSetUpdateExpression(obj) {
  const buildDescriptors = compose(
    map(([key, value]) => ({
      expr: `#${key} = :${key}`,
      name: { [`#${key}`]: key },
      value: { [`:${key}`]: value },
    })),
    toPairs
  );
  const descriptors = buildDescriptors(obj);

  const buildExpression = compose((expr) => `SET ${expr}`, join(", "), pluck("expr"));
  const buildAttrNames = compose(mergeAll, pluck("name"));
  const buildAttrValues = compose(mergeAll, pluck("value"));

  const expression = buildExpression(descriptors);
  const attrNames = buildAttrNames(descriptors);
  const attrValues = buildAttrValues(descriptors);

  return {
    UpdateExpression: expression,
    ExpressionAttributeNames: attrNames,
    ExpressionAttributeValues: attrValues,
  };
}
Example #2
Source File: index.js    From cross-chain-realitio-proxy with MIT License 6 votes vote down vote up
buildGenericConditionExpression = curry(function _buildGenericConditionExpression(exprAttr, obj) {
  const buildDescriptors = compose(
    map(([key, value]) => ({
      expr: `#${key} = :${key}`,
      name: { [`#${key}`]: key },
      value: { [`:${key}`]: value },
    })),
    toPairs
  );
  const descriptors = buildDescriptors(obj);

  const buildExpression = compose(join(" and "), pluck("expr"));
  const buildAttrNames = compose(mergeAll, pluck("name"));
  const buildAttrValues = compose(mergeAll, pluck("value"));

  const expression = buildExpression(descriptors);
  const attrNames = buildAttrNames(descriptors);
  const attrValues = buildAttrValues(descriptors);

  return {
    [exprAttr]: expression,
    ExpressionAttributeNames: attrNames,
    ExpressionAttributeValues: attrValues,
  };
})