-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_views.js
More file actions
42 lines (42 loc) · 1.9 KB
/
db_views.js
File metadata and controls
42 lines (42 loc) · 1.9 KB
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
{
"_id": "_design/views",
"views": {
"revisions": {
"map": "function (doc) {\n if(doc.type === \"app\") {\n emit(doc._id, doc._rev)\n }\n}\n\n"
},
"all_users": {
"map": "function (doc) {\n if(doc.type === \"user\") {\n for (app in doc.apps) {\n emit(doc.apps[app].id, {id: doc._id, used: doc.apps[app].used_inv, free: doc.apps[app].free_inv})\n }\n }\n}"
},
"waitlist_docs": {
"map": "function (doc) {\n if (doc.type === \"waitlist\") {\n emit(doc.app, doc);\n }\n}"
},
"waitlist_users": {
"map": "function (doc) {\n if (doc.type === \"waitlist\") {\n emit(doc.app, {rev: doc._rev, users: doc.users});\n }\n}"
},
"admins": {
"map": "function (doc) {\n if (doc.type === \"app\") {\n emit(doc.admin, doc._id);\n }\n}"
},
"apps_per_user": {
"map": "function (doc) {\n var list = []\n if (doc.type === \"user\") {\n for (var i in doc.apps) {\n list.push(doc.apps[i].id)\n }\n emit(doc._id, list)\n }\n}"
},
"user_count": {
"map": "function (doc) {\n if(doc.type === \"user\") {\n for (app in doc.apps) {\n emit(doc.apps[app].id, 1)\n }\n }\n}",
"reduce": "_count"
},
"sent_invs": {
"map": "function (doc) {\n if (doc.type === 'inv') {\n emit(doc.app, 1);\n }\n}",
"reduce": "_count"
},
"free_invs": {
"map": "function (doc) {\n if(doc.type === \"user\") {\n for (app in doc.apps) {\n emit(doc.apps[app].id, doc.apps[app].free_inv)\n }\n }\n}",
"reduce": "_sum"
},
"waitlist_occupied": {
"map": "function (doc) {\n if (doc.type === 'waitlist' && !doc.appDeleted) {\n emit(doc.app, doc.users.length)\n }\n}"
},
"users_invs": {
"map": "function (doc) {\n if(doc.type === 'inv') {\n emit(doc.from, { \"recipient\": doc.to, \"app\": doc.app })\n }\n}"
}
},
"language": "javascript"
}