Add internal & external triggers/hooks

On record actions (insert, update, delete) I’d like to automatically have called:

  1. a UDF
  2. a serverless function

For both I’d like the data to contain the:
a) collection name
b) full record

I can provide use cases for both scenarios if that helps, let me know. Thanks.

Hi @RobertBright,

Yes, having more details would help us quite a lot.

Thanks,

Luigi

In general publishing events from FaunaDB will allow us to better itegrate with the AWS ecosystem in the same way DynamoDB does. A specific use case of this is building Event Sourced solutions on top of FaunaDB.

Given a log of events:

{
  "ref": Ref(Collection("order_stream"), "282842364888744451"),
  "ts": 1605999005510000,
  "data": {
    "eventName": "OrderPlaced",
    "orderId": "guid_123",
    "userId": "user_123",
    "amount": 100,
    "productId": "product_123",
    "stripeToken": "stripe_123"
  }
}

{
  "ref": Ref(Collection("order_stream"), "282843030393717251"),
  "ts": 1605998983670000,
  "data": {
    "eventName": "OrderChargeSucceeded",
    "orderId": "guid_123",
    "stripeData": {
      "fieldA": "field a",
      "fieldB": "field b"
    }
  }
}

{
  "ref": Ref(Collection("order_stream"), "282843519356240384"),
  "ts": 1605999450000000,
  "data": {
    "eventName": "OrderPlaced",
    "orderId": "guid_456",
    "userId": "user_123",
    "amount": 200,
    "productId": "product_456",
    "stripeToken": "stripe_456"
  }
}

{
  "ref": Ref(Collection("order_stream"), "282850645452521986"),
  "ts": 1606006246020000,
  "data": {
    "eventName": "OrderSucceeded",
    "orderId": "guid_123",
    "successField": "some value"
  }
}

and a trigger to fold the results:

Reduce(
  Lambda((acc, value) => Merge(acc, Select("data", Get(value)))),
  {},
  Paginate(Match(Index("order_events_by_order_id"), "guid_123"))
)

we can project for storage in another collection:

{
  data: [
    {
      eventName: "OrderSucceeded",
      successField: "some value",
      orderId: "guid_123",
      amount: 100,
      stripeData: {
        fieldA: "field a",
        fieldB: "field b"
      },
      productId: "product_123",
      stripeToken: "stripe_123",
      userId: "user_123"
    }
  ]
}

Raising events to Lambda will allow things like websocket responses through API Gateway as data moves through the pipeline of events. It also allows higher level integrations with other systems outside of FaunaDB.

FaunaDB is a great candidate for ES systems as there is a queryable database. We don’t need consumers to go through entire logs sequentially; we can just query for the data we want to roll up.

There are more technical details I’d be happy to go over if the team is interested, but hopefully this provides a few useful scenarios for building better serverless apps with Fauna.

Hi @RobertBright,

Webhooks are in our Roadmap, but unfortunately, I don’t have any ETA for such feature.
Tagging your request as Feature Requests helps us to prioritize and keep track on what users are looking for using Fauna.

Thanks,

Luigi