Data Model Package

The digit_data_model package is a comprehensive data modeling library for the project. It defines various classes, enums, and functions used throughout the project. The package is written in Dart and is primarily used in Flutter applications.

Features

  • Data Models: The package provides a set of predefined data models like DataModel, EntityModel, EntitySearchModel, AdditionalFields, AdditionalField, ClientAuditDetails, AuditDetails, etc. These models are used to structure the data in the project.

  • Model Provider: The package includes a ModelProvider abstract class that can be implemented to provide a list of models. It also includes a ModelProviderRegistry class to register and retrieve all model providers.

  • Data Model Type Enum: The package defines a DataModelType enum that represents the different types of data models in the project.

  • Mapping Annotations: The package uses the dart_mappable package to generate mapping code for the classes. This helps in converting the data models to and from JSON.

  • Data Repositories: The package provides abstract classes for data repositories, DataRepository, RemoteRepository, and LocalRepository, which can be extended to create repositories for different data models. It also includes error handling with InvalidApiResponseException.

  • Sql Store: The package includes a SqlStore class that can be used to store data in a SQLite database.

    • Here are the key features it provides to other packages:
      1. Database Connection: It provides a connection to the SQLite database. This connection is opened when the database is first accessed.
      2. Table Definitions: It defines the tables in the database. These tables correspond to various entities in the project.
      3. Database Operations: It provides methods for querying and manipulating the data in the tables. These methods can be used to perform CRUD (Create, Read, Update, Delete) operations on the data.
      4. Schema Version: It provides the schema version of the database. This can be used to handle database migrations.
      5. Drift Integration: It uses the Drift package for interacting with the SQLite database. This provides a reactive persistence library for Flutter and Dart.

Getting Started

To use this package, add the following dependency to your pubspec.yaml file:

dependencies:
  digit_data_model: ^0.0.0-dev.1

Usage

Here are some examples of how to use the DataModel package in your project:

Extend the EntityModel or EntitySearchModel class and implement the required methods.

    class ExampleSearchModel extends EntitySearchModel {
  ExampleSearchModel({
    required this.employeeId,
    required this.attendanceDate,
    required this.status,
  });
}
    class ExampleAdditionalFields extends AdditionalFields {
  ExampleAdditionalFields({
    required this.field1,
    required this.field2,
  });
}

Extend the LocalRepository class and implement the required methods.

    class ExampleLocalRepository
        extends LocalRepository<ExampleModel, ExampleSearchModel> {
    ExampleLocalRepository(super.sql, super.opLogManager);
    }

Extend the RemoteRepository class and implement the required methods.

    class ExampleRemoteRepository
        extends RemoteRepository<ExampleModel, ExampleSearchModel> {
  ExampleRemoteRepository(super.apiClient, super.opLogManager);
    }

Libraries

blocs/boundary/boundary
blocs/facility/facility
blocs/product_variant/product_variant
blocs/project_facility/project_facility
blocs/service/service
blocs/service_definition/service_definition
blocs/user/user
data/data_repository
data/local_store/no_sql/schema/entity_mapper_listener
data/local_store/no_sql/schema/oplog
data/local_store/sql_store/sql_store
data/local_store/sql_store/tables/address
data/local_store/sql_store/tables/attributes
data/local_store/sql_store/tables/boundary
data/local_store/sql_store/tables/document
data/local_store/sql_store/tables/downsync
data/local_store/sql_store/tables/downsync_criteria
data/local_store/sql_store/tables/facility
data/local_store/sql_store/tables/identifier
data/local_store/sql_store/tables/individual
data/local_store/sql_store/tables/locality
data/local_store/sql_store/tables/localization
data/local_store/sql_store/tables/name
data/local_store/sql_store/tables/package_tables/attendance
data/local_store/sql_store/tables/package_tables/attendance_register
data/local_store/sql_store/tables/package_tables/attendee
data/local_store/sql_store/tables/package_tables/hf_referral
data/local_store/sql_store/tables/package_tables/household
data/local_store/sql_store/tables/package_tables/household_member
data/local_store/sql_store/tables/package_tables/referral
data/local_store/sql_store/tables/package_tables/side_effect
data/local_store/sql_store/tables/package_tables/staff
data/local_store/sql_store/tables/package_tables/stock
data/local_store/sql_store/tables/package_tables/stock_reconciliation
data/local_store/sql_store/tables/package_tables/task
data/local_store/sql_store/tables/package_tables/task_resource
data/local_store/sql_store/tables/pgr_service
data/local_store/sql_store/tables/product
data/local_store/sql_store/tables/product_variant
data/local_store/sql_store/tables/project
data/local_store/sql_store/tables/project_beneficiary
data/local_store/sql_store/tables/project_facility
data/local_store/sql_store/tables/project_product_variant
data/local_store/sql_store/tables/project_resource
data/local_store/sql_store/tables/project_staff
data/local_store/sql_store/tables/project_type
data/local_store/sql_store/tables/service
data/local_store/sql_store/tables/service_attributes
data/local_store/sql_store/tables/service_definition
data/local_store/sql_store/tables/target
data/local_store/sql_store/tables/user
data/oplog/oplog
data/repositories/local/address
data/repositories/local/base/attributes_base
data/repositories/local/base/facility_base
data/repositories/local/base/individual_base
data/repositories/local/base/product_base
data/repositories/local/base/product_variant_base
data/repositories/local/base/project_base
data/repositories/local/base/project_facility_base
data/repositories/local/base/project_product_variant_base
data/repositories/local/base/project_resource_base
data/repositories/local/base/project_staff_base
data/repositories/local/base/service_attributes_base
data/repositories/local/base/service_base
data/repositories/local/base/service_definition_base
data/repositories/local/base/user_base
data/repositories/local/boundary
data/repositories/local/facility
data/repositories/local/individual
data/repositories/local/pgr_service
data/repositories/local/product_variant
data/repositories/local/project
data/repositories/local/project_facility
data/repositories/local/project_resource
data/repositories/local/project_staff
data/repositories/local/service
data/repositories/local/service_definition
data/repositories/oplog/oplog
data/repositories/remote/attributes
data/repositories/remote/boundary
data/repositories/remote/facility
data/repositories/remote/individual
data/repositories/remote/pgr_service
data/repositories/remote/product
data/repositories/remote/product_variant
data/repositories/remote/project
data/repositories/remote/project_facility
data/repositories/remote/project_product_variant
data/repositories/remote/project_resource
data/repositories/remote/project_staff
data/repositories/remote/service
data/repositories/remote/service_attributes
data/repositories/remote/service_definition
data/repositories/remote/user
data_model
The data_model.dart file contains the definitions of various classes and enums used in the project. It also exports several other files that are part of the data model. The MappableLib annotation is used to generate mapping code for the classes in this library.
data_model.init
models/entities/address
models/entities/address_type
models/entities/attributes
models/entities/beneficiary_type
models/entities/blood_group
models/entities/boundary
models/entities/document
models/entities/facility
models/entities/gender
models/entities/identifier
models/entities/individual
models/entities/locality
models/entities/name
models/entities/name_model_converter
models/entities/product
models/entities/product_variant
models/entities/project
models/entities/project_facility
models/entities/project_product_variant
models/entities/project_resource
models/entities/project_staff
models/entities/project_type
models/entities/service
models/entities/service_attributes
models/entities/service_definition
models/entities/target
models/entities/user
models/entities/user_action
models/oplog/oplog_entry
models/pgr_complaints/pgr_address
models/pgr_complaints/pgr_complaints
models/pgr_complaints/pgr_complaints_response
models/project_type/project_type_model
utils/app_exception
utils/constants
utils/typedefs
utils/utils