Skip to content

Instantly share code, notes, and snippets.

@onosendi
Created February 28, 2023 03:36
Show Gist options
  • Save onosendi/3feeafb8265256259fe5c5b9f6f6b737 to your computer and use it in GitHub Desktop.
Save onosendi/3feeafb8265256259fe5c5b9f6f6b737 to your computer and use it in GitHub Desktop.
const R = require('ramda');
const userRegAttrs = [
{ reg_id: 1, attr_name: 'foo', attr_value: 1 },
{ reg_id: 1, attr_name: 'bar', attr_value: 3 },
];
const user_id = 1;
const res = R.pipe(
R.map(R.omit(['reg_id'])),
R.map(R.mergeRight({ user_id })),
)(userRegAttrs);
console.log(res);
// [
// { user_id: 1, attr_name: 'foo', attr_value: 1 },
// { user_id: 1, attr_name: 'bar', attr_value: 3 }
// ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment