conserv-datasource v1.0.0
conserv-datasource
The conserv-datasource
package is designed to centralize and abstract all business logic related to data operations within the Conserv ecosystem. It allows various applications to consume and manipulate data without the need to understand the underlying business logic, table joins, or data relationships.
Features
- Data Access Abstraction: Simplify data retrieval and manipulation by encapsulating the logic within easy-to-use functions.
- Centralized Business Logic: Ensure consistency across applications by centralizing business rules.
- Type Safety: Built with TypeScript for a more predictable codebase that's less prone to runtime errors.
Installation
To install conserv-datasource
, run the following command:
npm install @conserv/conserv-datasource
Usage
After installing the package, you can import and use the provided functions in your application. Here's an example of how to use the getSensorReadingsForRange function:
import { getSensorReadingsForRange } from '@conserv/conserv-datasource';
const sensorReadings = await getSensorReadingsForRange({
sensorId: 1,
start: new Date('2022-01-01T00:00:00.000Z'),
end: new Date('2022-01-02T23:59:59.999Z'),
});
console.log(sensorReadings);
Functions
getSensorReadingsForRange
Retrieve sensor readings within a specified date range, including readings from linked sensors.
Parameters:
- sensorId (number): The ID of the sensor to retrieve readings for.
- start (Date | undefined): The start date of the range.
end (Date | undefined): The end date of the range.
Returns: Promise<Readings[]>: An array of Readings objects.
Contributing
We welcome contributions to conserv-datasource. If you have suggestions or issues, please open an issue on our GitHub repository.
1 year ago