19ea7db9aef6a86c19911e684295e22a613085be.svn-base
872 Bytes
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
39
40
41
42
/*
* facet.js: Chainable search functions for Loggly facet searches.
*
* (C) 2010 Nodejitsu Inc.
* MIT LICENSE
*
*/
var util = require('util'),
Search = require('./search').Search;
//
// function Facet (facet, query, client, callback)
// Chainable facet search object for Loggly API
//
var Facet = exports.Facet = function (facet, query, client, callback) {
if (['date', 'ip', 'input'].indexOf(facet) === -1) {
var error = new Error('Cannot search with unknown facet: ' + facet);
if (callback) {
return callback(error);
}
else {
throw error;
}
}
//
// Set the baseUrl to be facet/:facet?
//
this.baseUrl = ['facets', facet + '?'].join('/');
//
// Call the base constructor.
//
Search.call(this, query, client, callback);
};
//
// Inherit from `loggly.Search`.
//
util.inherits(Facet, Search);