Created
April 10, 2015 02:17
-
-
Save RichardLitt/4e2f86e68b6b743a9ccf to your computer and use it in GitHub Desktop.
db.put not returning response
This file contains hidden or 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
| db.get(documentId).then(function (value) { | |
| // if (err && err.name !== 'not_found') { | |
| // return console.log('Failed to get ' + documentId + 'from db', err) | |
| // } | |
| /* Instantiate the object if it doesn't exist yet */ | |
| value = value || {} | |
| value._id = documentId | |
| /* Add in the selection to the selections array */ | |
| value.selections = value.selections || [] | |
| value.selections.push(selection) | |
| /* Get rid of prototypes so we can put this to the database */ | |
| value = JSON.parse(JSON.stringify(value)) | |
| console.log('value', value) | |
| return db.put(value) | |
| }).then(function (response) { | |
| console.log('response', response) | |
| // if (err) { console.log('Failed to save selection', err) } | |
| // console.log('Stored ' + response.id + ' away...', response) | |
| // PouchDB.sync('test', 'http://54.164.111.240:5984/test') | |
| }).catch(function (err) { | |
| console.log(err) | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment