search method

  1. @override
FutureOr<List<ProjectStaffModel>> search(
  1. ProjectStaffSearchModel query, [
  2. String? userId
])
override

The search method searches for entities that match the given query.

Implementation

@override
FutureOr<List<ProjectStaffModel>> search(
  ProjectStaffSearchModel query, [
  String? userId,
]) async {
  return retryLocalCallOperation(() async {
    final selectQuery = sql.select(sql.projectStaff).join([]);
    final results = await (selectQuery
          ..where(buildAnd([
            if (query.id != null)
              sql.projectStaff.id.equals(
                query.id!,
              ),
          ])))
        .get();

    return results.map((e) {
      final data = e.readTable(sql.projectStaff);

      return ProjectStaffModel(
        id: data.id,
        tenantId: data.tenantId,
        rowVersion: data.rowVersion,
        projectId: data.projectId,
        channel: data.channel,
        endDate: data.endDate,
        isDeleted: data.isDeleted,
        staffId: data.staffId,
        startDate: data.startDate,
        userId: data.userId,
      );
    }).toList();
  });
}