comforttore.blogg.se

Mudlet string functions
Mudlet string functions





mudlet string functions
  1. MUDLET STRING FUNCTIONS HOW TO
  2. MUDLET STRING FUNCTIONS UPDATE
  3. MUDLET STRING FUNCTIONS PLUS
  4. 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.

  • five And finally, we will delete the entire contents of the enemies table.ĭb:eq db:eq(field reference, value) Returns a database expression to test if the field in the sheet is equal to the value.
  • four Here, we will delete anything which matches the same kind of query as db:fetch uses- namely, anyone who is in the city of San Francisco.
  • three As above, but this example just passes in the row id directly.
  • This example shows getting the row id from a table.
  • two When passed a number, will delete the record for that _row_id.
  • one When passed an actual result table that was obtained from db:fetch, it will delete the record for that table.
  • enemies, true ) Those deletion commands will do in order: city, "San Francisco" )) db : delete ( mydb.
  • If the query is simply true, then it will truncate the entire contents of the sheet.Įnemies = db : fetch ( mydb.
  • Otherwise, it deletes every record which matches the query pattern which is specified as with b:get.
  • If it is a table that contains a _row_id (e.g., a table returned by db:get) it deletes just that record.
  • If it is a simple number, it deletes a specific row by _row_id.
  • The argument for query tries to be intelligent: namedb - observe that we use the REAL type by default instead and a default of 0 local sql_add = ] conn : execute ( sql_add ) conn : commit () end end db:delete db:delete(sheet reference, query) Deletes rows from the specified sheet. namedb - order should be a text field, so note that we specify it's type with TEXT and the default value at the end with "" local sql_add = ] conn : execute ( sql_add ) conn : commit () end - here is an another example, in one where we need to add a field that is a number if someperson. order = nil then - do not do the things you see here elsewhere else. If there is no key, means it doesn't exist yet, so it should be added. people ) - this requires at least one entry in the database to work if next ( test ) then local _, someperson = next ( test ) - in this example, we want to add an order key.

    mudlet string functions

    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:

    mudlet string functions

    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.

    mudlet string functions

    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.







    Mudlet string functions