Module ejdb

Simple binding for ejdb to lua

Functions

open (file, mode) Open a ejdb database
query (collection, query) Create a new query

Class db

db:put ([id], collection, document) Put a document into a collection
db:exec (query, callback) Execute a JQL query
db:close () Close a database handle
db:get (collection, id) Retrieve a document from the database
db:get (collection, id) Delete a document from the database
db:remove_collection (collection) Delete a collection from the database
db:rename_collection (old_name, new_name) Delete a collection from the database
db:ensure_collection (collection) Ensure a collection on the database
db:ensure_index (collection, field, mode) Ensure a index in a collection
db:remove_index (collection, field, mode) Remove a index from a collection
db:get_meta () Retrieve database structure

Class jql

jql:set (placeholder, index, value) Set a value in the query
jql:set_regex (placeholder, index, value) Set a regex value in the query


Functions

open (file, mode)
Open a ejdb database

Parameters:

  • file string The database file to open
  • mode string The modestring. `w` stands for truncate, `r` stands for read only. Empty string is normal open mode

Returns:

    db The opened database

Or

  1. nil
  2. string Error Message
query (collection, query)
Create a new query

Parameters:

  • collection string To collection to operate on
  • query string The query to prepare

Returns:

    jql The created query

Or

  1. nil
  2. string Error Message

Class db

Database handle
db:put ([id], collection, document)
Put a document into a collection

Parameters:

  • id integer The id of the inserted document (optional)
  • collection string The collection to insert into
  • document string or table The document to insert. Can be a json string or a table

Returns:

    integer ID of new document

Or

  1. nil
  2. string Error Message
db:exec (query, callback)
Execute a JQL query

Parameters:

  • query jql The query to execute
  • callback function(id,data) Callback to execute for each found document

Returns:

    integer Number of documents matched

Or

  1. nil
  2. string Error Message
db:close ()
Close a database handle
db:get (collection, id)
Retrieve a document from the database

Parameters:

  • collection string The collection to work on
  • id integer ID of the document to get

Returns:

    table document content

Or

  1. nil
  2. string Error Message
db:get (collection, id)
Delete a document from the database

Parameters:

  • collection string The collection to work on
  • id integer ID of the document to get

Returns:

    index of the deleted document

Or

  1. nil
  2. string Error Message
db:remove_collection (collection)
Delete a collection from the database

Parameters:

  • collection string The collection to work on

Returns:

    true

Or

  1. nil
  2. string Error Message
db:rename_collection (old_name, new_name)
Delete a collection from the database

Parameters:

  • old_name string The collection to rename
  • new_name string Name for the collection to have afterwards

Returns:

    true

Or

  1. nil
  2. string Error Message
db:ensure_collection (collection)
Ensure a collection on the database

Parameters:

  • collection string The collection to work on

Returns:

    true

Or

  1. nil
  2. string Error Message
db:ensure_index (collection, field, mode)
Ensure a index in a collection

Parameters:

  • collection string The collection to work on
  • field string JSON Pointer to the field
  • mode string List of mode chars: `i`=i64, `s`=str, `f`=double, `u`=unique

Returns:

    true

Or

  1. nil
  2. string Error Message
db:remove_index (collection, field, mode)
Remove a index from a collection

Parameters:

  • collection string The collection to work on
  • field string JSON Pointer to the field
  • mode string List of mode chars: `i`=i64, `s`=str, `f`=double, `u`=unique

Returns:

    true

Or

  1. nil
  2. string Error Message
db:get_meta ()
Retrieve database structure

Returns:

    table Structure of the database

Or

  1. nil
  2. string Error Message

Class jql

JQL Query
jql:set (placeholder, index, value)
Set a value in the query

Parameters:

  • placeholder string The placeholder to set
  • index integer Index of something (?)
  • value The value to set this placeholder to
jql:set_regex (placeholder, index, value)
Set a regex value in the query

Parameters:

  • placeholder string The placeholder to set
  • index integer Index of something (?)
  • value string The regex to search for
generated by LDoc 1.4.6 Last updated 2021-02-01 09:24:05