-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert
More file actions
executable file
·46 lines (39 loc) · 1.19 KB
/
Copy pathconvert
File metadata and controls
executable file
·46 lines (39 loc) · 1.19 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
43
44
45
46
#!/usr/bin/env node
'use strict';
const { MongoClient } = require('mongodb');
const mysql = require('mysql');
const config = require('./config');
const convertMemberProfile = require('./modules/member-profile');
const convertThreadAndPost = require('./modules/thread-and-post');
const convertAttachment = require('./modules/attachments');
const convertPmMessage = require('./modules/pm-message');
function createConnection(config) {
return new Promise((resolve, reject) => {
let mysqlConnecion = mysql.createConnection(config.mysql);
MongoClient.connect(config.mongo.url, { useNewUrlParser: true, useUnifiedTopology: true }, (err, server) => {
if (err) {
reject(err);
}
resolve({
mysql: mysqlConnecion,
mongo: server.db(config.mongo.db)
});
});
});
}
let conns;
createConnection(config).then(_conns => {
conns = _conns;
return convertMemberProfile(config, conns);
}).then(() => {
return convertAttachment(config, conns);
}).then(() => {
return convertThreadAndPost(config, conns);
}).then(() => {
return convertPmMessage(config, conns);
}).then(() => {
console.log("Finished!");
process.exit(0);
}).catch(err => {
console.log(err)
});