search method
FutureOr<List<StockReconciliationModel> >
search(
- StockReconciliationSearchModel query, [
- String? userId
override
The search
method searches for entities that match the given query.
Implementation
@override
FutureOr<List<StockReconciliationModel>> search(
StockReconciliationSearchModel query, [
String? userId,
]) async {
return retryLocalCallOperation(() async {
final selectQuery = sql.select(sql.stockReconciliation).join([]);
final results = await (selectQuery
..where(
buildAnd(
[
if (query.facilityId != null)
sql.stockReconciliation.facilityId
.equals(query.facilityId!),
if (query.productVariantId != null)
sql.stockReconciliation.productVariantId
.equals(query.productVariantId!),
if (query.clientReferenceId != null)
sql.stockReconciliation.id.equals(
query.id!,
),
if (query.productVariantId != null)
sql.stockReconciliation.productVariantId.equals(
query.productVariantId!,
),
if (query.facilityId != null)
sql.stockReconciliation.facilityId.equals(
query.facilityId!,
),
if (userId != null)
sql.stockReconciliation.auditCreatedBy.equals(
userId,
),
],
),
))
.get();
return results.map((e) {
final data = e.readTable(sql.stockReconciliation);
return StockReconciliationModel(
id: data.id,
tenantId: data.tenantId,
facilityId: data.facilityId,
productVariantId: data.productVariantId,
referenceId: data.referenceId,
referenceIdType: data.referenceIdType,
physicalCount: data.physicalCount,
calculatedCount: data.calculatedCount,
commentsOnReconciliation: data.commentsOnReconciliation,
dateOfReconciliation: data.dateOfReconciliation,
clientReferenceId: data.clientReferenceId,
rowVersion: data.rowVersion,
additionalFields: data.additionalFields == null
? null
: StockReconciliationAdditionalFieldsMapper.fromJson(
data.additionalFields!,
),
isDeleted: data.isDeleted,
);
}).toList();
});
}