Miscreated

Miscreated

Not enough ratings
[ModResource] MisDB
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
19.295 KB
21 Aug, 2019 @ 8:47am
31 Aug, 2019 @ 10:04am
3 Change Notes ( view )

Subscribe to download
[ModResource] MisDB

Description
MisDB
This is a Modding Resource, This WONT do anything on its own

MisDB Provides Mods With a Method for "Data Persistance"
Via JSON File Backed "Pages" and "Collections".
Based on a Module to Providing a "Pure Lua" implementation
'Similar' to flatDB/NoDB

MisDB Takes a Lua Table Converts it to JSON, and we call that a "Page"
These "Pages" are Grouped into Named "Collections" and Stored as Seperate Files,
One for Each Different Collection in a Folder with this "MisDB Objects" Name
And Placed in the Specified Base Directory (Relative to Your Server Root)
eg:

For a MisDB Called "MyModsData" with a Collection Named "Settings"
and Stored in the BaseDir "MisDBdata" :
[ServerRoot]>{BaseDir}/{MisDB Name}/{Collection Name} ServerRoot>/MisDBdata/MyModsData/Settings


Methods:
To use this you need to Include the following line to load the script before using it Script.ReloadScript("scripts/MisDB/MisDB.lua") * MisDB:Create(BaseDir, Name) ~> TableObject(Your Main MisDB Object) Creates a New MisDB Object to Store Collections Backed by files in [ServerRoot]>{BaseDir}/{Name} With the Returned {Object} then: * {Object}:Collection(Name) ~> CollectionObject(Table/Object defining this Collection) Create/Fetch a New Collection in this MisDB (Non Existant Collections Are autoCreated) the Returned {Collection} then provides the following Methods: * {Collection}:GetPage(pageId) Fetch The Contents of a "Page" from this "Collection" By Specified PageID ! This Will return nil, with a message as the Second return var if the Page Does Not Exist * {Collection}:SetPage(pageId,data) Set The Contents of a "Page" from this "Collection" By Specified PageID ? Returns the "written to disk" Copy of the Page Content you Set ? Use this to save your page data and use the return to verify against your data * {Collection}:PurgePage(pageId) Remove a "Page" from this "Collection" By Specified PageID ? returns true/nil and a message with the result --! You "Should" be Using the GetPage/SetPage functions and Editing your --! Collection a Page at a Time using Local Copies, helps Performance(less I/O Calls) --! Provides some Protection from any invalid Writes if you allways check the pagedata
Popular Discussions View All (1)
0
21 Sep, 2019 @ 8:34am
General
Theros