forked from Zilliqa/Devex-apollo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreindex.js
38 lines (31 loc) · 1.18 KB
/
reindex.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
import apollo from "apollo-server-express";
import cors from "cors";
import express from "express";
import mongoose from "mongoose";
import { range } from "./util.js";
import GQLSchema from "./gql/schema2.js";
import Api from "./datasource/api.js";
import config from "./config/config.js";
import {
txBlockReducer,
txnReducer,
transitionReducer,
} from "./mongodb/reducer.js";
import { TxBlockModel, TxnModel, TransitionModel } from "./mongodb/model.js";
mongoose.connect(config.dbUrl, { ...config.mongooseOpts });
let connection = mongoose.connection;
connection.once("open", function () {
console.log("MongoDB database connection established successfully");
TxnModel.collection.reIndex(finished => {
console.log('finished re indexing TxnModel');
});
TxBlockModel.collection.reIndex(finished => {
console.log('finished re indexing TxBlockModel');
});
TxnModel.collection.getIndexes({full: true}).then(indexes => {
console.log("TxnModel indexes:", indexes);
}).catch(console.error);
TxBlockModel.collection.getIndexes({full: true}).then(indexes => {
console.log("TxBlockModel indexes:", indexes);
}).catch(console.error);
});