Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit c1c473e

Browse files
committed
Working with new lib
1 parent 5d34a2c commit c1c473e

File tree

4 files changed

+118
-13
lines changed

4 files changed

+118
-13
lines changed

index.js

+23-13
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
const fs = require("fs");
2-
var ndjson = require('ndjson');
1+
const redis = require('./redis.js');
2+
const ndjson = require('iterable-ndjson')
3+
const fs = require('fs')
4+
const source = fs.createReadStream('./users.json')
35

4-
fs.createReadStream('./users.json')
5-
.pipe(ndjson.parse())
6-
.on('data', function(obj) {
6+
async function import_users() {
7+
let userIndex = 0;
8+
9+
for await (const obj of ndjson.parse(source)) {
710
let user = obj.actor_login;
8-
console.log("user: " + obj.actor_login);
9-
10-
substr = "";
11-
for (var i = 0; i < user.length; i++) {
12-
substr += user.charAt(i);
13-
console.log(substr);
14-
}
15-
})
11+
console.log(`user(${userIndex}): ${user}`);
12+
await redis.set(`users:${userIndex}`, user);
13+
userIndex++;
14+
}
15+
16+
process.exit(0);
17+
};
18+
19+
import_users();
20+
21+
// substr = "";
22+
// for (var i = 0; i < user.length; i++) {
23+
// substr += user.charAt(i);
24+
// //console.log(substr);
25+
// }

package-lock.json

+90
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
},
1818
"homepage": "https://github.com/ovsoinc/gitbackup#readme",
1919
"dependencies": {
20+
"ioredis": "^4.11.2",
21+
"iterable-ndjson": "^1.1.0",
2022
"ndjson": "^1.5.0"
2123
}
2224
}

redis.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const Redis = require('ioredis');
2+
3+
module.exports = new Redis(process.env.REDIS_URL);

0 commit comments

Comments
 (0)