warframe

This is the documentation page for Module:Database


Database contains helper methods for creating and maintaining /data subpages on the wiki that act as databases. For convention, we will use MongoDB's terminology for NoSQL-like databases and mapping them to wiki equilvalents:

A database can have multiple collections and a collection can have multiple documents. Likewise, a /data subpage can have multiple Lua tables that can have multiple data entries.

In most cases, when viewing /data contents as a tree structure, a "database" refers to the Level 1 (root) table, a "collection" refers to Level 2 table(s), and a "document" refers to any tables from Level 3 and beyond (nested table entries).

For example: return { ["Collection 1 Name"] = { ["Document 1 Index"] = { SomeKey = 1, AnotherKey = { "Some Data" } }, ["Document 2 Index"] = { SomeKey = 2, AnotherKey = { "More Data" } } }, ["Collection 2 Name"] = { ["Document 3 Index"] = { SomeKey = 3, DifferentKey = true } } }

Usage

Module

local Database = require('Module:Database')

Documentation

Package items

database._createIndex(database, collectionNames, indexKey) (function)
Adding an index key to table entries. Key to be indexed by must exist in all table entries and not have a nil value.
Parameters:
  • database A Lua table in a /data subpage (table)
  • collectionNames A table of collection names to only add new indexes to; if collection does not exist, creates a new table in database (table)
  • indexKey Key to be indexed by; must not be a key nested within a table value in a document (string)
Returns: Updated database with new indexes (table)
database._indexByInternalName(database, collectionNames) (function)
Adding another index key that maps InternalNames to table entries for module use. Direct invokes from articles should index by localized name.
Parameters:
  • database A Lua table in a /data subpage (table)
  • collectionNames A table of collection names to only add new indexes to (table)
Returns: Updated database with new indexes (table)
database._indexByLocalizedName(database, collectionNames) (function)
Adding another index key that maps Names to table entries for article use.
Parameters:
  • database A Lua table in a /data subpage (table)
  • collectionNames A table of collection names to only add new indexes to (table)
Returns: Updated database with new indexes (table)

Created with Docbunto

See Also


Code