

- MUDLET STRING FUNCTIONS HOW TO
- MUDLET STRING FUNCTIONS UPDATE
- MUDLET STRING FUNCTIONS PLUS
- MUDLET STRING FUNCTIONS SERIES
One of the most common of such is incrementing an existing field in a db:set() operation, as so:ĭb : fetch ( mydb. Use this function with caution, but it is very useful in some circumstances. db:exp db:exp(string) Returns the string as-is to the database.

then, we'll tell the database to create it if it doesn't exist - fetch the data we've got in our sample database local test = db : fetch ( ndb.
MUDLET STRING FUNCTIONS UPDATE
at first, update your db:create schema to have the new field. If a database has a sheet named enemies, you can obtain a reference to that sheet by simply doing:

You use these references to construct queries. This instance can be used to get references to the sheets (and from there, fields) that are defined within the database. Returns a reference of an already existing database. REPLACE - The old record which matched the unique index is dropped, and the new one is added to replace it.

IGNORE - The command that would add a record that violates uniqueness just fails silently.A hard error is thrown, cancelling the script. For sheets with unique indexes, you may specify a _violations key to indicate how the db layer handle cases where the data is duplicate (unique index is violated). The second sheet has two indexes, but one is unique: it isn’t possible to add two items to the enemies sheet with the same name. It has one index, a compound index tracking the combination of name and area. enemies, ) The above will create a database with two sheets the first is kills and is used to track every successful kill, with both where and when the kill happened.
MUDLET STRING FUNCTIONS SERIES
Each table is a series of key-value pairs to set the values of the sheet, -but if any keys do not exist then they will be set to nil or the default value.
MUDLET STRING FUNCTIONS PLUS
Returns nil plus the error message if the operation failed (so it won't raise an a runtime error in Mudlet). As such it is advisable that if you use a UNIQUE index, you test those values before you attempt to insert a new row. If any of these rows would violate a UNIQUE index, a lua error will be thrown and execution will cancel.
MUDLET STRING FUNCTIONS HOW TO
They are in addition to the LuaSQL sqlite driver that's available directly within Mudlet (also see the LuaSQL manual for comparison).įor a tutorial on how to get started with the database functions, see here.ĭb:add db:add(sheet reference, table1, …, tableN) Adds one or more new rows to the specified sheet. These database functions make using a database with Mudlet easier.
