Class luchia.core.document

Core document handler class.

Implements the methods necessary to handle documents. Note that for most cases, the document handling methods in luchia.document should be used; this module provides the core functionality that those higher-level methods use.

See the core.document.lua example for more detail.

Info:

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

Methods

luchia.core.document:new(self, params) Creates a new core document handler.
luchia.core.document:add_attachment(attachment) Add an inline attachment to a document.
luchia.core.document:prepare_request_data(server) Prepare document for a server request.


Methods

luchia.core.document:new(self, params)
Creates a new core document handler.

In order to send a document via the core server methods, a document object must be created, and passed to the 'data' parameter of luchia.core.server:request.

Parameters:

  • self
  • params Optional. A table with the metadata necessary to create a new document object.
    • id Optional. The document ID. If provided, this is copied into the document itself.
    • rev Optional. The document revision. If provided, this is copied into the document itself.
    • document Optional. A table representing the document to be stored in CouchDB. This table is converted to proper JSON format before being sent to the database.

Returns:

    A new document object.

Usage:

    document = luchia.core.document:new(params)
luchia.core.document:add_attachment(attachment)
Add an inline attachment to a document.

This method should not usually be called directly, instead use the higher-level luchia.document:add_inline_attachment.

Parameters:

Returns:

    The document table with the attachment added. Note that this does not return the full document object.

Usage:

    document_table = document:add_attachment(attachment)
luchia.core.document:prepare_request_data(server)
Prepare document for a server request.

This method is called by luchia.core.server:prepare_request_data to allow the document object to properly prepare the data for a server request.

Parameters:

  • server Required. The server object to prepare the request for.

Usage:

    document:prepare_request_data(server)
generated by LDoc 1.4.6 Last updated 2021-02-26 22:36:58