drive-config
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "drive-config", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A wrapper for mantaining json config files on Google Drive", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# drive-config | ||
A npm module for maintaining user config files (in json) on Google Drive. | ||
`npm install drive-config` | ||
## About | ||
@@ -10,3 +12,3 @@ We can take advantage of Google Drive's appdata folder to store a users config data for our application. The user cannot see these files, but can delete config data and revoke our app's access on their Drive by clicking the gear icon in the top right -> Settings -> Manage Apps -> Options Dropdown. | ||
#### Setup | ||
### Setup | ||
```javascript | ||
@@ -22,11 +24,9 @@ var googleAuth = require('google-auth-library'); | ||
let service = new driveConfig(oauth2Client); | ||
let driveConfigClient = new driveConfig(oauth2Client); | ||
``` | ||
#### List | ||
### List | ||
Gets all files in a user's google drive for your application | ||
```javascript | ||
let service = new driveConfig(oauth2Client); | ||
service.list().then(files => { | ||
driveConfigClient.list().then(files => { | ||
// do something with files | ||
@@ -36,22 +36,18 @@ }).catch(err => { | ||
}); | ||
// Resolves as an array of files | ||
[ | ||
{ | ||
id: String, | ||
name: String, | ||
data: Object, | ||
createdTime: Datetime, | ||
modifiedTime: Datetime, | ||
}, | ||
... | ||
] | ||
``` | ||
#### Create | ||
### Create | ||
Makes a new files in the user's google drive | ||
```javascript | ||
let service = new driveConfig(oauth2Client); | ||
driveConfigClient.create(fileName, data).then(file => { | ||
// do something with the file | ||
}).catch(err => { | ||
// handle errors | ||
}); | ||
``` | ||
service.create(fileName, data).then(file => { | ||
### Get | ||
Gets a file from a user's google drive with a fileId | ||
```javascript | ||
driveConfigClient.get(fileId).then(file => { | ||
// do something with the file | ||
@@ -61,4 +57,37 @@ }).catch(err => { | ||
}); | ||
``` | ||
// Resolves as a file | ||
### Get by name | ||
Gets a list of files that have a specific name | ||
```javascript | ||
driveConfigClient.getByName(fileName).then(files => { | ||
// do something with the list of files | ||
}).catch(err => { | ||
// handle errors | ||
}); | ||
``` | ||
### Update | ||
Updates a file on a user's google drive | ||
```javascript | ||
driveConfigClient.update(fileId, data).then(file => { | ||
// do something with the file | ||
}).catch(err => { | ||
// handle errors | ||
}); | ||
``` | ||
### Destroy | ||
Completely delete's a file from a user's google drive | ||
```javascript | ||
driveConfigClient.destory(fileId).then(() => { | ||
// do something next | ||
}).catch(err => { | ||
// handle errors | ||
}); | ||
``` | ||
### File Object | ||
```javascript | ||
// Example of what is returned from most methods | ||
{ | ||
@@ -68,5 +97,5 @@ id: String, | ||
data: Object, | ||
createdTime: Datetime, | ||
modifiedTime: Datetime, | ||
createdTime: Date, | ||
modifiedTime: Date, | ||
} | ||
``` | ||
``` |
9999
97