-
Notifications
You must be signed in to change notification settings - Fork 7
/
create-indexes.js
85 lines (81 loc) · 1.85 KB
/
create-indexes.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
db = db.getSiblingDB('agora')
print('');
print('Creating indexes for "' + db.getName() + '"');
print('');
const collections = [
{
name: 'geneinfo',
indexes: [
{ ensembl_gene_id: 1, hgnc_symbol: 1 },
{ hgnc_symbol: 1 },
{ nominations: -1, hgnc_symbol: 1 }
]
},
{
name: 'genes',
indexes: [
{ ensembl_gene_id: 1, tissue: 1, model: 1 },
{ ensembl_gene_id: 1, model: 1 },
{ hgnc_symbol: 1, tissue: 1, model: 1 }
]
},
{
name: 'geneslinks',
indexes: [
{ geneA_ensembl_gene_id: 1 },
{ geneB_ensembl_gene_id: 1 },
]
},
{
name: 'genesmetabolomics',
indexes: [
{ ensembl_gene_id: 1 }
]
},
{
name: 'genesproteomics',
indexes: [
{ ensembl_gene_id: 1 }
]
},
{
name: 'proteomicstmt',
indexes: [
{ ensembl_gene_id: 1 }
]
},
{
name: 'proteomicssrm',
indexes: [
{ ensembl_gene_id: 1 }
]
},
{
name: 'genesbiodomains',
indexes: [
{ ensembl_gene_id: 1 }
]
},
{
name: 'biodomaininfo',
indexes: [
{ name: 1 }
]
}
];
let results;
for (let collection of collections) {
print('Collection: ' + collection.name);
for (let index of collection.indexes) {
print('Creating index...');
printjson(index);
results = db[collection.name].createIndex(index);
if (results && results.ok === 1) {
print(results.numIndexesBefore < results.numIndexesAfter ? 'Success!' : 'Index already exists.');
}
else {
print('Failed: ' + results.note ? results.note : 'N/A');
}
}
print('');
}