Module couchdb

Access to CouchDB.

This module provides actions that allow access to CouchDB.

The module uses Luchia to interface with CouchDB, so it must be installed and configured correctly.

For all actions below that support the 'server' parameter: the 'server' parameter is a table of connection parameters to the CouchDB server, see here for details.

If things aren't working, be sure to check the log file, as configured in luchia/conf.lua.

Info:

  • Copyright: 2011-2015 Chad Phillips
  • Author: Chad Phillips

Actions

couchdb_add_attachment Add an attachment to a document.
couchdb_create_document Create a document.
couchdb_delete_attachment Delete an attachment from a document.
couchdb_delete_document Delete a document.
couchdb_retrieve Retrieve general data.
couchdb_retrieve_attachment Retrieve an attachment from a document.
couchdb_retrieve_document Retrieve a document.
couchdb_update_document Update a document.


Actions

couchdb_add_attachment
Add an attachment to a document.
  • action string couchdb_add_attachment
  • attachment_name string (Optional) File name for the attachment.
  • content_type string MIME type of the attachment.
  • database string Database to connect to.
  • document_id string (Optional) The document ID. If not provided, a new empty document will be created.
  • document_rev string The current document revision, required if attaching to an existing document.
  • file_path string File path to the attachment.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_add_attachment'. This will contain 'id' and 'rev' keys of the updated document on success.

Usage:

    {
      action = "couchdb_add_attachment",
      attachment_name = "attachment.txt",
      content_type = "text/plain",
      database = "example_db",
      document_id = "example_doc",
      document_rev = "1-5bfa2c99eefe2b2eb4962db50aa3cfd4",
      file_path = "/tmp/attachment.txt",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_create_document
Create a document.
  • action string couchdb_create_document
  • database string Database to connect to.
  • document tab A table of data representing the docuement to create.
  • document_id string (Optional) The document ID, one will be generated by the server if not provided.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_create_document'. This will contain 'id' and 'rev' keys of the created document on success.

Usage:

    {
      action = "couchdb_create_document",
      database = "example_db",
      document = {
        foo = "bar",
      },
      document_id = "example_doc",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_delete_attachment
Delete an attachment from a document.
  • action string couchdb_delete_attachment
  • attachment_name string The attachment name.
  • database string Database to connect to.
  • document_id string The document ID.
  • document_rev string The current document revision.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_delete_attachment'. This will contain 'id' and 'rev' keys of the updated document on success.

Usage:

    {
      action = "couchdb_delete_attachment",
      attachment_name = "attachment.txt",
      database = "example_db",
      document_id = "example_doc",
      document_rev = "1-5bfa2c99eefe2b2eb4962db50aa3cfd4",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_delete_document
Delete a document.
  • action string couchdb_delete_document
  • database string Database to connect to.
  • document_id string The document ID.
  • document_rev string The current document revision.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_delete_document'. This will contain 'id' and 'rev' keys of the deleted document on success.

Usage:

    {
      action = "couchdb_delete_document",
      database = "example_db",
      document_id = "example_doc",
      document_rev = "1-5bfa2c99eefe2b2eb4962db50aa3cfd4",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_retrieve
Retrieve general data.

General retrieval function, this can be used to fetch data from any valid path, such as for views, etc.

  • action string couchdb_retrieve
  • database string Database to connect to.
  • path string The path to retrieve. This should not include the database.
  • query_parameters tab (Optional) A table of query parameters to pass to the server.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the data in after loading. Defaults to 'couchdb_retrieve'. This will contain a 'data' key on success with a table representing the data.

Usage:

    {
      action = "couchdb_retrieve",
      database = "example_db",
      path = "_design/foo/_view/bar",
      query_parameters = {
        revs = "true",
      },
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_retrieve_attachment
Retrieve an attachment from a document.
  • action string couchdb_retrieve_attachment
  • attachment_name string The attachment name.
  • database string Database to connect to.
  • document_id string The document ID.
  • file_path string File path to write the retrieved attachment to.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_retrieve_attachment'. This will contain 'attachment_name' and 'file_path' keys of the retrieved attachment on success.

Usage:

    {
      action = "couchdb_retrieve_attachment",
      attachment_name = "attachment.txt",
      database = "example_db",
      document_id = "example_doc",
      file_path = "/tmp/attachment.txt",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_retrieve_document
Retrieve a document.
  • action string couchdb_retrieve_document
  • database string Database to connect to.
  • document_id string The document ID.
  • query_parameters tab (Optional) A table of query parameters to pass to the server.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the document in after loading. Defaults to 'couchdb_retrieve_document'. This will contain 'document', 'id' and 'rev' keys on success, 'document' is a table representing the document.

Usage:

    {
      action = "couchdb_retrieve_document",
      database = "example_db",
      document_id = "example_doc",
      query_parameters = {
        revs = "true",
      },
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
couchdb_update_document
Update a document.
  • action string couchdb_update_document
  • database string Database to connect to.
  • document tab A table of data representing the docuement to update.
  • document_id string The document ID.
  • document_rev string The current document revision.
  • server tab (Optional) Table of server connection parameters.
  • storage_area string (Optional) The storage area to store the server response in. Defaults to 'couchdb_update_document'. This will contain 'id' and 'rev' keys of the updated document on success.

Usage:

    {
      action = "couchdb_update_document",
      database = "example_db",
      document = {
        foo = "bar",
      }
      document_id = "example_doc",
      document_rev = "1-5bfa2c99eefe2b2eb4962db50aa3cfd4",
      server = profile.couchdb_server_params,
      storage_area = "example_storage",
    }
generated by LDoc 1.4.6 Last updated 2021-04-08 08:59:59