-
Notifications
You must be signed in to change notification settings - Fork 7
/
helpers.js
38 lines (35 loc) · 835 Bytes
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Logging result body, used in callbacks.
*/
module.exports.logBody = (error, result) => {
if (error) {
console.error(error);
} else {
console.log(result.body);
}
};
/**
* Parsing and logging list of titles from the result, used in callbacks.
*/
module.exports.logTitles = (error, result) => {
if (error) {
console.error(error);
} else {
const hits = result.body.hits.hits;
console.log(hits.map((hit) => hit._source.title));
}
};
module.exports.logAggs = (field, error, result) => {
if (error) {
console.error(error);
} else {
console.log(result.body.aggregations[field]);
}
};
module.exports.logResultBody = (error, result) => {
if (error) {
console.error(error);
} else {
console.log(result.body);
}
};