laren0815
laren0815

Reputation: 263

mongoosastic fire "TypeError: doc.execPopulate(...).then is not a function"

I've just updated my packages with npm update. After I made a test of my project, the error:

TypeError: doc.execPopulate(...).then is not a function
    at model.postSave (/myHome/myNodeJsServer/node_modules/mongoosastic/lib/mongoosastic.js:620:28)

was fired.

The error is in MyModel.save(); triggered.

What can I do now?

UPDATE:

My real code:

 global.DBModel.store.findOne({Email: data.Email}, function (err, store) {
            if (err)
                return cb({err: {status: 500, error: err}});
            if (!store) {
                delete data.isConfirm;
                delete data.isBlocked;
                if (data.geo_with_lat_lon && data.geo_with_lat_lon.lat && data.geo_with_lat_lon.lon) {
                    var lat = parseFloat(data.geo_with_lat_lon.lat);
                    var lon = parseFloat(data.geo_with_lat_lon.lon);
                    data.geo_with_lat_lon = {lon: lon, lat: lat};
                }
                var store = new global.DBModel.store(data);
                store.save(cb); //Here fire the error
            } else {
                return cb({status: 409, error: new Error("User exist!")});
            }
        });

Upvotes: 1

Views: 2359

Answers (2)

laren0815
laren0815

Reputation: 263

The problem was that I used a lot to old version. Everything was updated, but in the package.json the old version was fixed.

npm install [email protected] --save did the problem solved.

Or:

npm install -g npm-check-updates
npm-check-updates -u
npm install

Upvotes: 1

enRaiser
enRaiser

Reputation: 2636

Can you try

return  store.save(cb);

or

 store.save(cb);
 next();

Upvotes: 0

Related Questions