pouchdb / upsert

PouchDB plugin for upsert() and putIfNotExists() functions
Apache License 2.0
149 stars 25 forks source link

doc id is not required even when sent. #48

Closed gusreyes01 closed 7 years ago

gusreyes01 commented 7 years ago

Here's my function, I'm trying to do an upsert but keep getting doc id is required as a response.

        function _upsert(obj, _paramdb) {
            console.log(obj.id) /// has value!!
            return _paramdb.upsert(obj.id, function (doc) {
                    return doc;
                }).then(function (res) {
                    console.log(res);
                    // success, res is {rev: '1-xxx', updated: true, id: 'myDocId'}
                }).catch(function (err) {
                    console.log(err);
                    // error
                });

        }
Error: doc id is required
    at upsertInner (pouchdb.upsert.js:11)
    at Oe.upsert (pouchdb.upsert.js:57)
    at Object._upsert [as upsert] (localstorage-factory.js:78)
    at studentSuccess (student-controller.js:90)
    at ionic.bundle.js:24508
    at processQueue (ionic.bundle.js:29104)
    at ionic.bundle.js:29120
    at Scope.$eval (ionic.bundle.js:30372)
    at Scope.$digest (ionic.bundle.js:30188)
    at Scope.$apply (ionic.bundle.js:30480)
gusreyes01 commented 7 years ago

Not an issue, doc id must be a string. Silly mistake.