Created
August 16, 2019 12:39
-
-
Save tristankirkpatrick/32d2c9fe0d87206c499bace13a9b9754 to your computer and use it in GitHub Desktop.
This file contains 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 Twit = require('twit') | |
var twitter = new Twit({ | |
consumer_key: 'xxx', | |
consumer_secret: 'xxx', | |
access_token: 'xxx', | |
access_token_secret: 'xxx', | |
timeout_ms: 60 * 1000, // optional HTTP request timeout to apply to all requests. | |
strictSSL: true, // optional - requires SSL certificates to be valid. | |
}) | |
var GoogleSheets = require('google-drive-sheets'); | |
var mySheet = new GoogleSheets('xxx'); | |
mySheet.getRows(1, function(err, rowData) { | |
console.log('Pulled in ' + rowData.length + ' rows from Google Sheets'); | |
for (i = 0; i < rowData.length; i++) { | |
var twitterhandle = rowData[i].twitterhandle | |
let specialism = rowData[i].specialism | |
let handle = rowData[i].twitterhandle | |
const mongo = require('mongodb').MongoClient; | |
const uri = "mongodb+srv://[logindetails]@edutwitter-1-jkgue.mongodb.net/test?retryWrites=true&w=majority"; | |
//const uri = "http://192.168.1.150:32776"; | |
const client = new mongo(uri, { useNewUrlParser: true }); | |
client.connect(err => { | |
const collection = client.db("twitterteachers").collection("teachers_test"); | |
collection.find({Name: msg.Name}, {$exists: true}).toArray(function(err, doc) //find if a value exists | |
{ | |
if(doc){ | |
console.log("User already in the db"); // print out what it sends back | |
} | |
else if(!doc) // if it does not | |
{ | |
console.log("Not in the DB, should upload"); | |
} | |
}) | |
}) | |
} | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment