/tg/ Station 13 - Modules - TypesProc Details

json_database

Represents a json file being used as a database in the data/ folder. Changes made here will save back to the associated file, with recovery. Will defer writes until later if multiple happen in the same tick. Do not add an extra cache on top of this. This IS your cache.

Procs

getReturns the cached data. Be careful on holding onto this data for too long, as it can mutate when other stuff changes it. Do not mutate it yourself.
get_keyReturns the data with the given key. For arrays, this is a number. Be careful on holding onto this data for too long, as it can mutate when other stuff changes it. Do not mutate it yourself.
insertInserts the data at the end of what is assumed to be an array, and queues a save.
pick_and_take_keyPicks the data of a random key and then removes that key from the database. Since the list is no longer inside the database, you can mutate and use it as you like.
removeRemoves the data at the given item, and queues a save. For dictionaries, this can be the key. For arrays, this can be the value.
replaceReplaces the cache with the new data completely, and queues a save. Do not touch the new data after passing it in.
set_keySets the data at the key to the value, and queues a save.

Proc Details

get

Returns the cached data. Be careful on holding onto this data for too long, as it can mutate when other stuff changes it. Do not mutate it yourself.

get_key

Returns the data with the given key. For arrays, this is a number. Be careful on holding onto this data for too long, as it can mutate when other stuff changes it. Do not mutate it yourself.

insert

Inserts the data at the end of what is assumed to be an array, and queues a save.

pick_and_take_key

Picks the data of a random key and then removes that key from the database. Since the list is no longer inside the database, you can mutate and use it as you like.

remove

Removes the data at the given item, and queues a save. For dictionaries, this can be the key. For arrays, this can be the value.

replace

Replaces the cache with the new data completely, and queues a save. Do not touch the new data after passing it in.

set_key

Sets the data at the key to the value, and queues a save.