Giter Club home page Giter Club logo

mongoose-rollback's People

Contributors

snkz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mongoose-rollback's Issues

VersionError - No matching document found for id "..."

I try to revert documents to a previous version which is marked by a property called _lastSavedVersion.

But when I try this:

Model.find({ edited: true }, (err, results) => {
  if (err) {
    next(err);
  }
    
  results.forEach((result) => {
    const lastSavedVersion = result._lastSavedVersion;

    result.revert(lastSavedVersion, (revertErr, hist) => {
      if (revertErr) {
        console.log('revert Error: ', revertErr);
        next(revertErr);
      }

        console.log('hist: ', hist);
      });
    });
    res.sendStatus(200);
  });
}

I get an Error saying:

{
    message: 'No matching document found for id "59e4756fc389a51c16f9fef3"',
    name: 'VersionError'
}

Any idea what I'm doing wrong or how I can make this work?

Edit: It correctly reverts the right document in the model_hist collection. But doesn't revert the original document.

Can't store delta in _hist collection

Currently delta data were stored in data like this

/* 1 */
{
    "_id" : ObjectId("587a3354a185ba2f002f75df"),
    "currentVersion" : 1,
    "data" : [ 
        {
            "createdAt" : ISODate("2017-01-14T14:19:00.815Z"),
            "_id" : ObjectId("587a3354a185ba2f002f75df"),
            "_version" : 0,
            "data" : "World",
            "name" : "Hello"
        }, 
        {
            "createdAt" : ISODate("2017-01-14T14:19:00.815Z"),
            "_id" : ObjectId("587a3354a185ba2f002f75df"),
            "_version" : 1,
            "data" : "Yo",
            "name" : "Hey",
            "__v" : 0
        }
    ],
    "__v" : 0
}

Is it possible to only store changed delta data here, this jsondiffpatch may help you.

"Trying to open unclosed connection." or doesn't work with no "conn"

Hey,

I've been having some problems trying to get this module to work. When I don't specify a db connection when instantiating the plugin, Model.RollbackModel returns undefined and all save() methods on my models fail to do anything. However, if I specify in a conn property, either as an actual connection object (in my case, I use createConnection rather than Mongoose's global form), or as a hard coded string, I get the dreaded "Trying to open unclosed connection." error from mongoose-rollback.js:29

Any ideas?
Thanks!
Matt

TypeError · model.toObject is not a function

Sometimes I get this error:
TypeErrornode_modules/mongoose-rollback/lib/save.js:56
TypeError · model.toObject is not a function
And this makes my server go down
Any idea about this?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.