/* Update Data to IOS Users*/
'use strict';
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://10.0.0.5:27017/";
var pgsqlUtils = require('./../../utils/pgsql.utils');
//Get Data from Mongo
MongoClient.connect(url, function(err, db) {
    if (err) throw err;
    var dbo = db.db("aiproddb");
         let skip = parseInt(process.argv[2]);
         dbo.collection("app_users5fa41afe6fc1e678a8344311").find().skip(skip).limit(40000).toArray(function(err, result) {
             if (err) throw err;
             result.forEach(element => {
                if(element.did){
                    let queryCitus = "Insert INTO events_5fa41afe6fc1e678a8344311(did,key,segment,eventtime) VALUES ('" + element.did + "','Login','{}','1607631293');"
                    // Citus Query
                    pgsqlUtils.executeQuery(queryCitus)
                        .then(res =>{
                             
                    })
                }
             });
         });
});

