existIDs<I extends Object> method
FutureOr<Iterable<I> >
existIDs<I extends Object>(
- List<
I?> ids, { - Transaction? transaction,
override
Implementation
@override
FutureOr<Iterable<I>> existIDs<I extends Object>(
List<I?> ids, {
Transaction? transaction,
}) {
var idsNotNull = ids is List<I> ? ids : ids.nonNulls.toList();
if (idsNotNull.isEmpty) return <I>[];
var cachedEntityByIDs = transaction?.getCachedEntitiesByIDs(
idsNotNull,
type: type,
);
var cachedIDs = cachedEntityByIDs?.keys.whereType<I>().toList();
List<I> notCachedIDs;
if (cachedIDs != null) {
notCachedIDs = idsNotNull.whereNotIn(cachedIDs).toList();
if (notCachedIDs.isEmpty) {
return idsNotNull;
}
} else {
notCachedIDs = idsNotNull;
}
checkNotClosed();
var op = TransactionOperationCount(
name,
operationExecutor,
matcher: ConditionIdIN(notCachedIDs),
transaction: transaction,
);
try {
return repositoryAdapter.doExistIDs(op, notCachedIDs).resolveMapped((
ids,
) {
return [...?cachedIDs, ...ids];
});
} catch (e, s) {
var message =
'existIDs> '
'cachedIDs: $cachedIDs ; '
'notCachedIDs: $notCachedIDs ; '
'op: $op';
_log.severe(message, e, s);
rethrow;
}
}