-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
42 lines (32 loc) · 945 Bytes
/
index.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
39
40
41
42
var lucene = function(nanoAdapter, options) {
if (!nanoAdapter) {
throw new Error('Required Nano Adapter not Found');
}
var nano = nanoAdapter;
var database = options && options.db ? options.db : null;
var fragment = options && options.fragment ? options.fragment : '_fti';
var _search = function(designDoc, viewName, requestParams, callback) {
if (!requestParams) {
throw new Error('Required Request Parameters');
}
if (!designDoc) {
throw new Error('Required Options: Design Document');
}
if (!viewName) {
throw new Error('Required Options: View Name');
}
var viewPath = fragment + '/local/' + database + '/_design/' +
designDoc + '/' + viewName;
var req = {
uri: viewPath,
method: 'GET',
path: viewPath,
qs: requestParams
};
return nano.relax(req, callback);
};
return {
search: _search
};
};
module.exports = lucene;