Class EntityAbstract

An entity represents a single object in the domain model.

Most entities are backed by a database table, but some entities may be transient and not persisted to the database, or may be backed by a different kind of data store.

Hierarchy (View Summary)

Constructors

Properties

Methods

Constructors

  • Parameters

    • parser: ObjectParser

    Returns Entity

Properties

parser: ObjectParser

Methods

  • Converts the Data object into a plain JSON representation, including all properties defined as getters in the subclass.

    The toJSON method dynamically identifies getter properties in the subclass and collects their values to construct a JSON object. This is particularly useful when you want to serialize the Data object for APIs, logging, or other use cases requiring JSON format.

    Returns Record<string, unknown>

    A plain object representing the Data instance with all getter properties.

    class LoginData extends Data<FormParser> {
    get username() {
    return this.parser.getString("username");
    }
    get password() {
    return this.parser.getString("password");
    }
    }

    const loginData = new LoginData(new FormParser(formData));
    console.log(JSON.stringify(loginData.toJSON()));
    // Output: { "username": "johndoe", "password": "secret" }