Created
May 30, 2018 18:35
-
-
Save JoaoVagner/2bc2e911480fe2670b3b349f9d94fd65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var admin = require("./node_modules/firebase-admin"); | |
var firebase = require("./node_modules/firebase"); | |
var serviceAccount = require("./credentials/joao_teste.json"); | |
admin.initializeApp({ | |
credential: admin.credential.cert(serviceAccount), | |
databaseURL: "https://teste-joao-19a9f.firebaseio.com" | |
}); | |
var db_firestore = admin.firestore(); | |
var MongoClient = require('mongodb').MongoClient; | |
var url = "mongodb://localhost:27017/ativos"; | |
// Connect to the db | |
MongoClient.connect(url, { useNewUrlParser: true }, function (err, db) { | |
if (err) throw err; | |
var dbo = db.db("ativos"); | |
var collection = dbo.collection("ativos"); | |
collection.find({}).limit(500).toArray(function (err, result) { | |
if (err) throw err; | |
result.forEach(function (value, i) { | |
// var addDoc = db_firestore.collection('callcenter_users').doc(value.id); | |
var addDoc = db_firestore.collection('callcenter_users').doc(value.matricula); | |
var insert = addDoc.set({ | |
id: value.id, | |
nome: value.nome, | |
data_nascimento: value.data_nascimento, | |
sexo: value.sexo, | |
matricula: value.matricula.replace(' ', ''), | |
titular: value.titular, | |
dac: value.gerenciadores[0][0].servicos[0][0].dac, | |
gerenciadores: value.gerenciadores[0][0] | |
}); | |
console.log("matricula" + value.matricula); | |
}) | |
db.close(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment