-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.js
66 lines (62 loc) · 2.29 KB
/
config.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module.exports = {
dbEndpoint: process.env.COUCHDB_ENDPOINT || 'localhost:5984',
dbName: process.env.COUCHDB_DATABASE || 'db',
dbUser: process.env.COUCHDB_USERNAME || 'couchdb',
dbPass: process.env.COUCHDB_PASSWORD || 'couchdb',
interval: process.env.OPTS_INTERVAL || 100,
startKey: process.env.OPTS_START_KEY || null,
endKey: process.env.OPTS_END_KEY || null,
pageSize: process.env.OPTS_PAGE_SIZE || 1000,
numPages: process.env.OPTS_NUM_PAGES || undefined,
batchSize: process.env.OPTS_BATCH_SIZE || 1000,
quiet: process.env.OPTS_QUIET || false,
tasks: process.env.OPTS_TASKS || {
"count-docs": (util, doc) => util.count('total_docs'),
// "audit-bad-docs": (util, doc) => {
// if (doc.status && doc.status === 'bad') {
// const object = { bad_doc_id: doc._id, status: doc.status }
// util.audit(object);
// }
// },
// "hash-doc-contents": (util, doc) => {
// const hash = util.hash(doc);
// util.log('SHA256 hash of doc: ' + hash);
// },
// "validate-schema": (util, doc) => {
// const schema = require('./test/schema.json');
// const data = require('./test/data.json');
// const valid = util.validate(schema, data);
// util.log(doc._id + ' is valid? ' + valid);
// },
// "dependent-updates": (util, doc) => {
// if (doc.childKeys) {
// const keys = doc.childKeys;
// // Do a bulk get for all childKeys
// util.nano.fetch(keys, (err, result) => {
// if (err) {
// console.log(err);
// } else {
// const newChildKeys = [];
// const rows = result.rows;
// const hasMissingChildKeys = false;
// // Only add docs to the newChildKeys that were found in the db
// rows.forEach(row => {
// if (row.doc) {
// newChildKeys.push(row.id);
// } else {
// hasOrphans = true;
// util.log('Missing child doc: ' + row.id);
// }
// });
// if (hasMissingChildKeys) {
// doc.childKeys = newChildKeys;
// util.nano.insert(doc, (err, result) => {
// console.log(result);
// });
// }
// }
// });
// }
// }
}
};