Created
April 8, 2015 23:53
-
-
Save superlou/05e1159c5f236c46d73d to your computer and use it in GitHub Desktop.
Dropbox Store
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 DropboxOnlineAdapter = DS.Adapter.extend({ | |
find: function(store, type, id, snapshot) { | |
var dropbox = this.container.lookup('service:dropbox'); | |
var path = this.filename(type, id); | |
return dropbox.files(path).then((result) => { | |
var data = { | |
id: id, | |
text: result | |
}; | |
var model = store.push(type, data); | |
return model; | |
}); | |
}, | |
findAll: function(store, type, sinceToken) { | |
var dropbox = this.container.lookup('service:dropbox'); | |
var dropboxFiles = dropbox.metadata('').then((result) => { | |
return result.contents.map((item) => { | |
return item.path.match(/\/([\w]*)\.fountain/)[1]; | |
}); | |
}).then((ids) => { | |
return ids.map((id) => { | |
return this.find(store, type, id); | |
}); | |
}); | |
console.log(dropboxFiles); | |
return dropboxFiles; | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment