Search Results for

    Show / Hide Table of Contents

    Class Database

    Database Singleton that allows to:

    • Store into Table and return any object extending Data;
    • Save them into local storage;
    • Supports abstract classes to select several types at once (e.g. inheritance).
    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    SingletonBehaviour
    SingletonBehaviour<Database>
    Database
    Inherited Members
    SingletonBehaviour<Database>.Instance
    SingletonBehaviour<Database>.Initialized
    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 Source

    FORMAT

    Declaration
    public const Formatting FORMAT = Indented
    Field Value
    Type Description
    Formatting

    JSON Format used while serializing data.

    Methods

    | Edit this page View Source

    Clear<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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    ResetDB()

    Reinitialize both cached and local database with default scriptable values.

    Declaration
    public static void ResetDB()
    | Edit this page View Source

    SaveDB()

    Write cached database in local storage.

    Declaration
    public static void SaveDB()
    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    • Edit this page
    • View Source
    In this article
    • Fields
      • FORMAT
    • Methods
      • Clear<T>()
      • Insert<T>(params T[])
      • ResetDB()
      • SaveDB()
      • Select<T>(ulong)
      • Select<T>(params ulong[])
    Back to top Generated by DocFX