forked from slickage/baron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
couchapp.js
85 lines (74 loc) · 1.4 KB
/
couchapp.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var config = require(__dirname + '/config');
var ddoc = {
_id: '_design/' + (config.couchdb.name || 'baron'),
views: {},
lists: {},
shows: {}
};
module.exports = ddoc;
ddoc.views.invoicesWithPayments = {
map: function(doc) {
if (doc.type === 'invoice') {
emit(doc._id, doc);
}
if (doc.type === 'payment') {
emit(doc.invoice_id, doc);
}
}
};
ddoc.views.invoices = {
map: function(doc) {
if (doc.type === 'invoice') {
emit(doc._id, doc);
}
}
};
ddoc.views.payments = {
map: function(doc) {
if (doc.type === 'payment') {
emit(doc.address, doc);
}
}
};
ddoc.views.paymentsById = {
map: function(doc) {
if (doc.type === 'payment') {
emit(doc._id, doc);
}
}
};
ddoc.views.paymentsBlockHash = {
map: function(doc) {
if (doc.type === 'payment') {
emit(doc.block_hash, doc);
}
}
};
ddoc.views.paymentsTxId = {
map: function(doc) {
if (doc.type === 'payment') {
emit(doc.tx_id, doc);
}
}
};
ddoc.views.watchedPayments = {
map: function(doc) {
if (doc.type === 'payment' && doc.watched) {
emit(doc.address, doc);
}
}
};
ddoc.views.lastBlockHash = {
map: function(doc) {
if (doc.type === 'blockhash') {
emit(doc.hash, doc);
}
}
};
ddoc.views.webhooks = {
map: function(doc) {
if (doc.type === 'webhook') {
emit([doc.invoice_id, doc.created], doc);
}
}
};