Class PumpAlarmEventRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Represents a MongoDB-backed repository for PumpAlarmEvent documents, exposing pump alarm event-specific data access through the IPumpAlarmEventRepository contract.
public class PumpAlarmEventRepository : MongoRepository<PumpAlarmEvent>, IMongoRepository<PumpAlarmEvent>, IPumpAlarmEventRepository
- Inheritance
-
PumpAlarmEventRepository
- Implements
- Inherited Members
- Extension Methods
Remarks
Inherits the generic MongoDB persistence capabilities of MongoRepository<T>, specializing them for the PumpAlarmEvent entity type.
Constructors
PumpAlarmEventRepository(IOptions<ApiSettings>, IMongoDatabase)
public PumpAlarmEventRepository(IOptions<ApiSettings> apiSettings, IMongoDatabase database)
Parameters
apiSettingsIOptions<ApiSettings>databaseIMongoDatabase
Methods
CreateIndexes()
Creates the indexes required for the collection. The base implementation is a no-op; derived classes should override this method to define their own indexes.
public override Task CreateIndexes()
Returns
DeleteByPatientId(ObjectId)
Deletes records associated with the specified patient identifier.
public Task DeleteByPatientId(ObjectId patientId)
Parameters
patientIdObjectIdThe unique identifier of the patient whose records should be deleted.
Returns
FindByDeviceIdAsync(string, DateTime?, DateTime?, int?)
Retrieves pump alarm events associated with the specified device, optionally filtered by a date range and capped by a maximum result count.
public Task<IEnumerable<PumpAlarmEvent>> FindByDeviceIdAsync(string deviceId, DateTime? from = null, DateTime? to = null, int? limit = null)
Parameters
deviceIdstringThe unique identifier of the device whose alarm events should be returned.
fromDateTime?Optional start of the date range used to filter the events.
toDateTime?Optional end of the date range used to filter the events.
limitint?Optional maximum number of alarm events to return.
Returns
- Task<IEnumerable<PumpAlarmEvent>>
A task that represents the asynchronous operation, containing the collection of pump alarm events matching the criteria.
FindLastByDeviceIdAsync(string)
Asynchronously retrieves the most recent pump alarm event associated with the specified device identifier. Returns null if no alarm event is found for the given device.
public Task<PumpAlarmEvent?> FindLastByDeviceIdAsync(string deviceId)
Parameters
deviceIdstringThe unique identifier of the device whose last pump alarm event is to be retrieved.
Returns
- Task<PumpAlarmEvent>
A task that represents the asynchronous operation, containing the most recent PumpAlarmEvent for the device, or null if none exists.
GetCollectionName()
When implemented in a derived class, returns the name of the MongoDB collection used to store documents of type PumpAlarmEvent.
public override string GetCollectionName()
Returns
- string
The MongoDB collection name as a string.
InsertAsync(PumpAlarmEvent)
Asynchronously inserts a pump alarm event into the underlying data store.
public Task InsertAsync(PumpAlarmEvent alarmEvent)
Parameters
alarmEventPumpAlarmEventThe pump alarm event to be persisted.
Returns
UpdateManyObjectIdByFiledNameAsync(string, ObjectId, ObjectId)
Asynchronously updates the ObjectId value of multiple records where the specified field currently matches the old identifier, replacing it with the new identifier.
public Task<long> UpdateManyObjectIdByFiledNameAsync(string fieldName, ObjectId newId, ObjectId oldId)
Parameters
fieldNamestringThe name of the field whose value should be updated.
newIdObjectIdThe new ObjectId value to assign to the matching records.
oldIdObjectIdThe existing ObjectId value used to identify the records to be updated.