Last active
June 18, 2024 02:44
-
-
Save koladilip/a79622f308886fc538b5357ae0ac63a0 to your computer and use it in GitHub Desktop.
All Custom Mappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"code":"[\n {\n \"input\": \"$.userId\",\n \"output\": \"$.user.id\"\n },\n {\n \"input\": \"$.discount\",\n \"output\": \"$.events[0].items[*].discount\"\n },\n {\n \"input\": \"$.products[?(@.category)].id\",\n \"output\": \"$.events[0].items[*].product_id\"\n },\n {\n \"input\": \"$.events[0]\",\n \"output\": \"$.events[0].name\"\n },\n {\n \"input\": \"$.products[?(@.category)].name\",\n \"output\": \"$.events[0].items[*].product_name\"\n },\n {\n \"input\": \"$.products[?(@.category)].category\",\n \"output\": \"$.events[0].items[*].product_category\"\n },\n {\n \"input\": \"$.products[?(@.category)].variations[*].size\",\n \"output\": \"$.events[0].items[*].options[*].s\"\n },\n {\n \"input\": \"$.products[?(@.category)].(@.price * @.quantity * (1 - $.discount / 100))\",\n \"output\": \"$.events[0].items[*].value\"\n },\n {\n \"input\": \"$.products[?(@.category)].(@.price * @.quantity * (1 - $.discount / 100)).sum()\",\n \"output\": \"$.events[0].revenue\"\n },\n {\n \"input\": \"$.products[?(@.category)].variations[*].length\",\n \"output\": \"$.events[0].items[*].options[*].l\"\n },\n {\n \"input\": \"$.products[?(@.category)].variations[*].width\",\n \"output\": \"$.events[0].items[*].options[*].w\"\n },\n {\n \"input\": \"$.products[?(@.category)].variations[*].color\",\n \"output\": \"$.events[0].items[*].options[*].c\"\n },\n {\n \"input\": \"$.products[?(@.category)].variations[*].height\",\n \"output\": \"$.events[0].items[*].options[*].h\"\n }\n]\n","name":"mappings_with_output","type":"Mappings","data":"{\n \"description\": \"Enter your data here\"\n }","bindings":"const bindings = {\n \"description\": \"Enter your bindings here\"\n };","result":{"output":"{\n \"user\": {\n \"id\": $.userId\n },\n \"events\": [{\n \"items\": ^.products[?((.category))].({\n \"discount\": $.discount,\n \"product_id\": .id,\n \"product_name\": .name,\n \"product_category\": .category,\n \"options\": .variations[*].({\n \"s\": .size,\n \"l\": .length,\n \"w\": .width,\n \"c\": .color,\n \"h\": .height\n })[],\n \"value\": .(.price * .quantity * (1 - $.discount / 100))\n })[],\n \"name\": $.events[0],\n \"revenue\": ^.products[?((.category))].(.price * .quantity * (1 - $.discount / 100)) .sum()\n }]\n}","langugage":"javascript"}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment