Class Database
Database Singleton that allows to:
Inheritance
Namespace: GGL.DB
Assembly: GGL.dll
Syntax
[AddComponentMenu("GG-Library/Singletons/Database")]
[HelpURL("https://ggl.yoannhaffner.com/articles/database.html")]
public class Database : SingletonBehaviour<Database>
Fields
| Edit this page View SourceFORMAT
Declaration
public const Formatting FORMAT = Indented
Field Value
Type | Description |
---|---|
Formatting | JSON Format used while serializing data. |
Methods
| Edit this page View SourceClear<T>()
Clear a table corresponding to type if it exists in database.
Declaration
public static void Clear<T>() where T : Data
Type Parameters
Name | Description |
---|---|
T | Type of the data to clear. |
Insert<T>(params T[])
Insert a list of items in the concerned table.
Declaration
public static void Insert<T>(params T[] data) where T : Data
Parameters
Type | Name | Description |
---|---|---|
T[] | data | Data to insert in database. |
Type Parameters
Name | Description |
---|---|
T | Type of the data to insert. Used as a table selector - which can be several tables if the type is abstract. |
ResetDB()
Reinitialize both cached and local database with default scriptable values.
Declaration
public static void ResetDB()
SaveDB()
Write cached database in local storage.
Declaration
public static void SaveDB()
Select<T>(ulong)
Select an item from the concerned table.
Declaration
public static T Select<T>(ulong id) where T : Data
Parameters
Type | Name | Description |
---|---|---|
ulong | id | ID of the data you're looking for. |
Returns
Type | Description |
---|---|
T |
Type Parameters
Name | Description |
---|---|
T | Type of the data to find. Used as a table selector - which can be several tables if the type is abstract. |
Select<T>(params ulong[])
Select a list of items. No params will return all data concerned table.
Declaration
public static IEnumerable<T> Select<T>(params ulong[] ids) where T : Data
Parameters
Type | Name | Description |
---|---|---|
ulong[] | ids | IDs of the data you're looking for. |
Returns
Type | Description |
---|---|
IEnumerable<T> |
Type Parameters
Name | Description |
---|---|
T | Type of the data to find. Used as a table selector - which can be several tables if the type is abstract. |