从Cloud Functions for Firebase中的URL获取ID

时间:2017-04-24 08:10:59

标签: javascript firebase google-cloud-functions

如果我得到这行代码:

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "increment_id": "[&1].saleId",
        "created_at": "[&1].saleDate",
        "shipping_amount": "[&1].shippingFeesWithoutTax",
        "shipping_tax_amount": "[&1].shippingFeesVTA",
        "grand_total": "[&1].totalAmount",
        "customer": {
          "entity_id": "[&2].customer.id",
          "firstname": "[&2].customer.firstName",
          "lastname": "[&2].customer.lastName",
          "dob": "[&2].customer.birthDate"
        },
        "order_items": {
          "*": {
            "item_id": "[&3].details[&1].detailsId",
            "sku": "[&3].details[&1].productCode",
            "name": "[&3].details[&1].productName",
            "qty_ordered": "[&3].details[&1].quantity",
            "row_total": "[&3].details[&1].grossPrice",
            "discount_amount": "[&3].details[&1].discount",
            "price_incl_tax": "[&3].details[&1].price",
            "tax_percent": "[&3].details[&1].VTA"
          }
        }
      }
    }
  }
]

我可以通过event.data.key;从uid获取密钥,但是如何从randomid获取id? randomkey由Swift中的childByAutoId生成。感谢。

1 个答案:

答案 0 :(得分:1)

如果您想获取为{randomid}使用生成的密钥:

const randomid= event.params.randomid;