These are chat archives for Automattic/mongoose

15th
Oct 2017
Ben Chiciudean
@benydc
Oct 15 2017 13:08
I want to do a full backup of the mongodb and then do incremental backups for each new data
is this possible?
Malik Hassan
@muhammad786
Oct 15 2017 13:10
yes it’s possible
mongodb has commands for taking backup
so you can schedule a script having these commands
Ben Chiciudean
@benydc
Oct 15 2017 13:12
but for example, if data is delete from prod mongodb, can the deletion be ignored on the backup?
Malik Hassan
@muhammad786
Oct 15 2017 13:13
let’s say you have captured one backup just now and anything deleted before it then definitely you would not get the deleted data within latest backup
Ben Chiciudean
@benydc
Oct 15 2017 13:14
that’s not my question
Malik Hassan
@muhammad786
Oct 15 2017 13:14
but deleted data should be available within old backups
after creating backup even if all data is deleted then there would not be any impact on older backups data
Ben Chiciudean
@benydc
Oct 15 2017 13:16
for example:
  1. I have existing A data on full backup
  2. A data get’s deleted from mongodb
  3. incremental backup runs
  4. snapshot will not contain A data
Is more like I want to merge the backup..
Malik Hassan
@muhammad786
Oct 15 2017 13:20
ok as per my information ... when we restore the data in mongodb from backup it keeps the old data and insert new one too ...
Fernando Lujan 🍁
@iamvfl_twitter
Oct 15 2017 18:36
Hey folks
Hoping someone’s around

Any idea why:

Bundle
    .findOneAndUpdate({ assetId }, { previewImageUrl }, { upsert: true })

doesn’t work as expected, but:

Bundle
          .findOneAndUpdate({ assetId }, { previewImageUrl }, { upsert: true }, () => {})

works? Feels unnecessary to have to pass in a callback function that I’m not making use of

The docs say you should be able to do it in Way #1, but it doesn’t seem to work (docs for ref: http://mongoosejs.com/docs/api.html#model_Model.findOneAndUpdate)
Fernando Lujan 🍁
@iamvfl_twitter
Oct 15 2017 18:50
Just feels ugly to have a no-op at the end of an otherwise clean statement ☹️
CuAnnan
@CuAnnan
Oct 15 2017 18:56
How do you check if the response of findOne is null?
Fernando Lujan 🍁
@iamvfl_twitter
Oct 15 2017 19:00
@CuAnnan
Thingy.findOne({ uniqueId: ’something' }, function (error, thingy) {
    if (error) {
        // Handle errors here. If findOne didn’t find anything it’ll
        // probably throw an error here
    }

    // This is what findOne returns in its callback. To see if this
    // is null you can do perform a simple if (thingy !== null) check
    console.log(thingy);
});