Skip to content

Repository database overview

Patrick Titzler edited this page Sep 3, 2016 · 3 revisions

The service creates a small repository database named transform_ in the CouchDB instance identified by environment variable TARGET_COUCH_DB_URL during startup.

Four views are defined in this database:

repository/events

This view lists document that contain event information.

repository/application_events

This view lists general application events, that are not specific to operations performed against the source database or the target database. A typical example is the [application] start event that documents the configuration, such as source database, target database, filters and transformation.

{
  "_id": "...",
  "_rev": "...",
  "task_id": "9565e09ad69a3c733c4bb2954e097940",
  "record_type": "event",
  "event_type": "start",
  "data": {
    "source": {
      "url": "https://somebody@some-couchdb-host/",
      "dbname": "source_database"
    },
    "target": {
      "url": "https://somebody@some-couchdb-host/",
      "dbname": "target_database"
    },
    "filter": {
      "server": {
        "name": "transform_service/exclude_deleted_docs",
        "definition": "function(doc, req) { if(doc._deleted) { return false; }  else { return true; }}"
      },
      "client": {
        "name": "sample_filter_functions/ignore_design_documents.js",
        "definition": "function (change) {\r\n\tif((! change) || (! change.doc) || (change.doc._id.startsWith('_design/'))) {\r\n\t\treturn false;\r\n\t}\r\n\telse {\r\n\t\treturn true;\r\n\t}\r\n}"
      }
    },
    "transformer": {
      "name": "sample_transform_function/add_timestamp_property.js",
      "definition": "function (doc) {if(doc) {doc.timestamp = new Date().toISOString();} return doc;}"
    }
  },
  "timestamp": "2016-09-02T21:37:36.487Z"
}
  • The task_id is an MD5 hash, identifying the unique combination of source/target database.
  • The filter property contains information about the server-side and/or client-side filters that are used.
  • The transformer property identifies the transformation routine

No Password information is stored for the source and target database.

repository/target_database_events

This view lists events related to target database processing, such as bulk-write failures.

repository/recovery

This view returns one recovery document for each unique source-db/target-db combination. Recovery documents are updated every time a batch of transformed documents was successfully written to the target database.

{
  "_id": "...",
  "_rev": "...",
  "task_id": "9565e09ad69a3c733c4bb2954e097940",
  "record_type": "recovery",
  "last_update_seq": "284515-ihD52CyROrqEER6I",
  "last_change_applied": "Fri Sep 02 2016 17:16:06 GMT-0700 (Pacific Daylight Time)"
}