UNPKG

@openhps/core

Version:

Open Hybrid Positioning System - Core component

63 lines 2.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DataFrameService = void 0; const data_1 = require("../data"); const DataService_1 = require("./DataService"); /** * The data frame service manages storage of complete data frames. */ class DataFrameService extends DataService_1.DataService { constructor(dataServiceDriver) { super(dataServiceDriver); } /** * Insert a new data frame * @param {DataFrame} frame Data frame to insert * @returns {DataFrame} Inserted frame */ insertFrame(frame) { return this.insert(frame.uid, frame); } /** * Find data frames created before a certain timestamp * @param {number} timestamp Timestamp * @param {FindOptions} [options] Find options * @returns {DataFrame[]} Array of data frames before the specified timestamp */ findBefore(timestamp, options) { return this._findTimestamp({ $lte: timestamp }, options); } /** * Find data frames created after a certain timestamp * @param {number} timestamp Timestamp * @param {FindOptions} [options] Find options * @returns {DataFrame[]} Array of data frames after the specified timestamp */ findAfter(timestamp, options) { return this._findTimestamp({ $gte: timestamp }, options); } /** * Find data frames by data object * @param {DataObject | string} dataObject Data object to get frames for * @param {FindOptions} [options] Find options. By default sorted by createdTimestamp in descending order * @returns {DataFrame[]} Array of data frames that contain the specified object */ findByDataObject(dataObject, options) { return this.findAll({ objects: { $elemMatch: { uid: dataObject instanceof data_1.DataObject ? dataObject.uid : dataObject, }, }, }, options || { sort: [['createdTimestamp', -1]], }); } _findTimestamp(timestampFilter, options) { return this.findAll({ createdTimestamp: timestampFilter, }, options); } } exports.DataFrameService = DataFrameService; //# sourceMappingURL=DataFrameService.js.map