Skip to content

Commit 8ab2a60

Browse files
author
GuustMetz
committed
feat: create setTimeRangeQuery
1 parent 67f3249 commit 8ab2a60

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

lib/utilities/setTimeRangeQuery.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
import { QueryBuilder } from "../database/utilities/QueryBuilder";
15+
16+
/**
17+
* function that sets a time range in a QueryBuilder.
18+
*
19+
* @param {object} timerange an object that defines a time range to add to the query
20+
* @param {number} timerange.from the lower bound of the time range
21+
* @param {number} timerange.to the upper bound of the time range
22+
* @param {string} attribute the model attribute for which the range will be set
23+
* @param {QueryBuilder} attribute queryBuider instance in which the time range will be set.
24+
* @returns {void}
25+
*/
26+
export function setTimeRangeQuery({ from = 0, to = Date.now() }, attribute, queryBuilder) {
27+
queryBuilder.where(attribute).between(from, to);
28+
}

0 commit comments

Comments
 (0)