Class PumpArchiveRepository
- Namespace
- adas_core.Infrastructure.Repositories
- Assembly
- adas-core.Infrastructure.dll
Repositorio de archivo para observaciones de bombas. Colección: archive_pumpobservations (configurable por ApiSettings.ArchivePumpObservations).
public class PumpArchiveRepository : MongoRepository<PumpObservation>, IMongoRepository<PumpObservation>, IPumpArchiveRepository
- Inheritance
-
PumpArchiveRepository
- Implements
- Inherited Members
- Extension Methods
Constructors
PumpArchiveRepository(IOptions<ApiSettings>, IMongoDatabase)
public PumpArchiveRepository(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
DeleteBeforeDate(DateTime)
Deletes all pump observations whose recording time is earlier than the specified cutoff date.
public Task DeleteBeforeDate(DateTime addDays)
Parameters
addDaysDateTimeThe cutoff date; observations with a timestamp before this value are removed.
Returns
FindByPatientIdAsync(ObjectId, DateTime?, DateTime?, int?)
Retrieves a collection of PumpObservation records for a specific patient, optionally filtered by a time range and limited in count, sorted by time in descending order.
public Task<IEnumerable<PumpObservation>> FindByPatientIdAsync(ObjectId patientId, DateTime? from = null, DateTime? to = null, int? limit = null)
Parameters
patientIdObjectIdThe identifier of the patient whose pump observations are being queried.
fromDateTime?Optional inclusive lower bound for the observation time. When provided, only observations on or after this time are returned.
toDateTime?Optional inclusive upper bound for the observation time. When provided, only observations on or before this time are returned.
limitint?Optional maximum number of observations to return. When null, all matching observations are returned.
Returns
- Task<IEnumerable<PumpObservation>>
A task that represents the asynchronous operation. The task result contains an IEnumerable<T> of matching observations ordered from newest to oldest.
GetCollectionName()
When implemented in a derived class, returns the name of the MongoDB collection used to store documents of type PumpObservation.
public override string GetCollectionName()
Returns
- string
The MongoDB collection name as a string.
InsertAsync(PumpObservation)
Asynchronously inserts a PumpObservation into the underlying MongoDB collection.
public Task InsertAsync(PumpObservation obs)
Parameters
obsPumpObservationThe pump observation to persist.
Returns
InsertManyAsync(IEnumerable<PumpObservation>)
Asynchronously inserts a batch of pump observations into the underlying data store. If the collection is empty, the method completes without performing any insertion.
public Task InsertManyAsync(IEnumerable<PumpObservation> observations)
Parameters
observationsIEnumerable<PumpObservation>The pump observations to insert into the collection.