UNPKG

2.37 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Source: lib/model/search/numeric.js</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14</head>
15
16<body>
17
18<div id="main">
19
20 <h1 class="page-title">Source: lib/model/search/numeric.js</h1>
21
22
23
24
25
26
27 <section>
28 <article>
29 <pre class="prettyprint source linenums"><code>var util = require('./util');
30
31/**
32
33 {
34 "numericrange": true,
35 "rangefrom": 13,
36 "rangeto": 17,
37 "numericrangefield": "channels.age.current-value",
38 }
39
40 {
41 numeric: {
42 channel: 'name'
43 from: 1
44 to: 10
45 }
46 }
47
48*/
49
50module.exports = function (params, query) {
51 if(!params) return;
52 query.numericrange = true;
53 query.numericrangefield = util.getFieldName(params);
54 var hasFrom = util.hasProp(params, "from"),
55 hasTo = util.hasProp(params, "to");
56 if(!hasFrom &amp;&amp; !hasTo) {
57 throw new Error("At least one of `from` or `to` properties has to be provided for numeric range search");
58 }
59 if(hasFrom) {
60 query.rangefrom = params.from;
61 }
62 if(hasTo) {
63 query.rangeto = params.to;
64 }
65};
66</code></pre>
67 </article>
68 </section>
69
70
71
72
73</div>
74
75<nav>
76 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Action.html">Action</a></li><li><a href="Channel.html">Channel</a></li><li><a href="Client.html">Client</a></li><li><a href="Raptor.html">Raptor</a></li><li><a href="RecordSet.html">RecordSet</a></li><li><a href="ResultSet.html">ResultSet</a></li><li><a href="ServiceObject.html">ServiceObject</a></li><li><a href="Stream.html">Stream</a></li><li><a href="User.html">User</a></li></ul><h3>Global</h3><ul><li><a href="global.html#Container">Container</a></li></ul>
77</nav>
78
79<br class="clear">
80
81<footer>
82 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Wed Nov 02 2016 11:15:06 GMT+0100 (CET)
83</footer>
84
85<script> prettyPrint(); </script>
86<script src="scripts/linenumber.js"> </script>
87</body>
88</html>