Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var dbName = 'platform-interview';
- var user = 'platform-interviewee';
- var password = 'plaid';
- var server = 'leranf-interview.plaid.com:27017/';
- var url = 'mongodb://' + user + ':' + password + '@' + server + dbName;
- var MongoClient = require('mongodb').MongoClient;
- var fs = require('fs');
- var serialize = function (client_id, item_id, institution_type) {
- return new Buffer(client_id + ',' + item_id + ',' + institution_type, 'utf8').toString('base64');
- };
- MongoClient.connect(url, function(err, db) {
- db.collection('items').find().toArray(function(err, data) {
- var tokens = '';
- data.forEach(function(item) {
- var newToken = serialize(item._client, item._id, item.institution_type) + '\n';
- tokens += newToken;
- });
- fs.writeFile('tokens.txt', tokens, 'utf8', function (err, data) {
- if (err) {
- console.log(err);
- } else {
- console.log('created new-line text file with all access-tokens');
- }
- });
- db.close();
- });
- });
Add Comment
Please, Sign In to add comment