-
Notifications
You must be signed in to change notification settings - Fork 0
/
setFirebase.js
35 lines (30 loc) · 915 Bytes
/
setFirebase.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
const firebase = require("firebase")
require("firebase/firestore")
const fs = require("fs")
const followers = JSON.parse(fs.readFileSync("followers.json", "utf-8"))
const f_lengh = followers.ids.length
firebase.initializeApp(JSON.parse(fs.readFileSync("secret/secretFirebase.json", "utf-8")))
var db = firebase.firestore()
const date = new Date().toString()
var index = -1
const exampleFunc = function() {
index++;
console.log("users", index, followers.ids[index])
db.collection("userIds").doc(followers.ids[index].toString()).set({
id: followers.ids[index],
followed_date: date
})
.then(() => {
console.log("Document successfully setted!")
})
.catch(function(error) {
console.error("Error adding document: ", error)
})
};
function loopSlowly(loop, interval) {
console.log('start...')
for(let i = 0; i < loop; i++) {
setTimeout(exampleFunc, i * interval);
}
}
loopSlowly(f_lengh - 1, 1000)