Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from InsideInc/master
adding update / put commands to google-bigquery project
- Loading branch information
Showing
3 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var request = require('request'); | ||
|
||
var put = function ( options ) { | ||
|
||
var getToken = require('./getToken')(options.iss, options.key); | ||
|
||
return function ( url, data, cb ) { | ||
|
||
getToken(function ( err, token ) { | ||
|
||
if (err) { return cb(err); } | ||
|
||
request.put({ | ||
url: 'https://www.googleapis.com/bigquery/v2' + url, | ||
qs: { | ||
access_token: token | ||
}, | ||
json: data | ||
}, function ( err, res, body ) { | ||
if ( err || res.statusCode !== 200 ) { | ||
//console.log(err || res); | ||
cb(err); | ||
} else { | ||
cb(undefined,body); | ||
} | ||
}); | ||
}); | ||
}; | ||
}; | ||
|
||
module.exports = put; |