0.3.4 • Published 2 years ago

@andrewcturing/faunadb v0.3.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

FaunaDB Event Sources

FaunaDB Event Sources collect data from FaunaDB (for example, changes to a collection) and emits them as individual events. These events can trigger Pipedream workflows, and are accessible as a real-time, private SSE stream, and via REST API.

Watch this video to learn how to create an event source to track changes to documents in a Fauna collection and build a Pipedream workflow to run on every change.

Sources

Changes to Documents in a Collection

Click here to create this source

The changes-to-collection.mjs source tracks add and remove events to documents in a specific collection. Each time you add or remove a document from this collection, this event source emits an event of the following shape:

{
  "ts": 1588738648630000,
  "action": "add",
  "document": {
    "@ref": {
      "id": "264744257335591434",
      "collection": {
        "@ref": {
          "id": "test",
          "collection": { "@ref": { "id": "collections" } }
        }
      }
    }
  }
}

If you set the Emit changes as a single event property to true, Pipedream will emit a single event with all the changes since the last time the source ran. That event has the following shape:

[
  {
    "ts": 1588738648630000,
    "action": "add",
    "document": {
      "@ref": {
        "id": "264744257335591434",
        "collection": {
          "@ref": {
            "id": "test",
            "collection": { "@ref": { "id": "collections" } }
          }
        }
      }
    }
  },
  {
    "ts": 1588739721810000,
    "action": "remove",
    "document": {
      "@ref": {
        "id": "264744257335591434",
        "collection": {
          "@ref": {
            "id": "test",
            "collection": { "@ref": { "id": "collections" } }
          }
        }
      }
    }
  }
]

Workflows

Here are a few example workflows you can copy and modify in any way: