Sask Vaccine Guide Code Docs
    Preparing search index...

    Core class for all db entities. Db entities must extend this class.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    id: number
    language: "english" | "french"
    message: string
    db: SQLiteDatabase

    An sqlite database connection.

    Methods

    • Saves the current object to the database.

      Returns Promise<void>

      All columns that are not nullable must contain a value. This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator (this also initializes the database).

      If a required field is empty or the entity prototype is not properly defined.

      Adds a row to the database with the objects data.

    • Clears all entities from the table.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      Returns Promise<void>

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource.

      If the entity prototype is not properly defined.

      Deletes all of the rows in the database.

    • Get the number of entities in the table.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      Returns Promise<number>

      The number of entities in the table.

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource.

      If the entity prototype is not properly defined.

    • Finds and returns all records of the current entity.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      Returns Promise<T[]>

      An array of entities.

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource.

      If the entity prototype is not properly defined.

    • Takes a option value of SELECT and/or WHERE. Retrieves in the SELECT format if given and all if not. Finds the first instance that matches WHERE

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      • this: new () => T & typeof default
      • options: { select?: { [key: string]: any }; where: { [key: string]: any } }

        an object which containst the query modifiers

      Returns Promise<null | T>

      An single BaseEntity type containing the first instance of the WHERE claus

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource. There must be a where value given and it must be the condiiton you want to select one

      If the entity prototype is not properly defined.

    • Get a list of all database column names.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      Returns Promise<ColumnMetadata[]>

      A list of column data.

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource.

      If the entity prototype is not properly defined.

    • Executes a query. It automatically replaces $table with the entity’s table name.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      • this: new () => T & typeof default
      • query: string

        A valid SQL query string. Use $table within the query to reference this entity's table name. Needs to return a list of objects

      • ...params: any[]

        Additional parameters for the query (optional).

      Returns Promise<any>

      An the result of the query the same way as the expo-sqlite database does see

      If the entity prototype is not properly defined.

      modifys the sqlite database based on the given query

      // The table name is "employees"
      const results = await Employee.query(
      "SELECT * FROM $table WHERE salary > ?",
      100000
      );
      // This runs:
      // SELECT * FROM employees WHERE salary > 100000
    • Executes a query that returns a list of objects of the type this is called with. It automatically replaces $table with the entity’s table name.

      Type Parameters

      • T extends default

        The type of the entity.

      Parameters

      • this: new () => T & typeof default
      • query: string

        A valid SQL query string. Use $table within the query to reference this entity's table name. Needs to return a list of objects

      • ...params: any[]

        Additional parameters for the query (optional).

      Returns Promise<T[]>

      An array of entities resulting from the query.

      This must be called from a class that extends BaseEntity, has one primary attribute, and the class has an Entity decorator. The mysql database must also be initialized using the hook useInitDataSource.

      If the entity prototype is not properly defined.

      // The table name is "employees"
      const results = await Employee.query(
      "SELECT * FROM $table WHERE salary > ?",
      100000
      );
      // This runs:
      // SELECT * FROM employees WHERE salary > 100000