Skip to content

Commit

Permalink
Merge branch 'master' into bump-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
bencevans committed Jan 30, 2014
2 parents e17070f + 8dcf6c7 commit 79bac89
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
temp.js
coverage
.idea
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,49 @@ var influx = require('influx');
var client = influx(host, port, username, password, database);
```


## Functions

```js
createDatabase(databaseName, callback) { }
```
Creates a new database - requires cluster admin privileges

```js
deleteDatabase(databaseName, callback) { }
```
Deletes a database - requires cluster admin privileges

```js
getDatabaseNames(callback) { }
```
Returns array of database names - requires cluster admin privileges

```js
getSeriesNames(databaseName, callback) { }
```
Returns array of series names from given database - requires database admin privileges


```js
createUser(databaseName, username, password, callback) { }
```
Creates a new database user - requires cluster admin privileges

```js
writePoint(seriesName, values, options, callback) { }
```
Writes point to database - requires database user privileges

```js
readPoints(query, callback) { }
```
Reads points from a database - requires database user privileges





As Jeff Atwood puts it... [Read the source, Luke](http://www.codinghorror.com/blog/2012/04/learn-to-read-the-source-luke.html). If you're still stuck, read the `./examples/*` files and the `./test.js` file.


Expand Down
22 changes: 19 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ InfluxDB.prototype.deleteDatabase = function(databaseName, callback) {

InfluxDB.prototype.getDatabaseNames = function(callback) {
request({
url: this.url('dbs'),
url: this.url('db'),
json: true
}, this._parseCallback(function(err, dbs) {
if(err) {
Expand All @@ -73,14 +73,29 @@ InfluxDB.prototype.getDatabaseNames = function(callback) {
}));
};


InfluxDB.prototype.getSeriesNames = function(databaseName,callback) {
request({
url: this.url('db/' + databaseName + '/series', {q: 'list series'}),
json: true
}, this._parseCallback(function(err, series) {
if(err) {
return callback(err, series);
}
return callback(err, _.map(series, function(series) { return series.name; }));
}));
};



InfluxDB.prototype.createUser = function(databaseName, username, password, callback) {
request.post({
request.post({
url: this.url('db/' + databaseName + '/users'),
headers: {
'content-type': 'application/json'
},
body: JSON.stringify({
username: username,
name: username,
password: password
}, null)
}, this._parseCallback(callback));
Expand Down Expand Up @@ -112,6 +127,7 @@ InfluxDB.prototype.writePoint = function(seriesName, values, options, callback)
headers: {
'content-type': 'application/json'
},
pool : 'undefined' != typeof options.pool ? options.pool : {},
body: JSON.stringify(data)
}, this._parseCallback(callback));
};
Expand Down

0 comments on commit 79bac89

Please sign in to comment.