These are chat archives for Automattic/mongoose

10th
Jun 2017
XHMM
@XHMM
Jun 10 2017 10:22
i don't know whether it's a bug ,can somebody have a look:
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const testSchema = new Schema({
    count:{
        type:Number,
        default:0
    }
})
const Test = mongoose.model('Test',testSchema);
mongoose.connect('mongodb://localhost:27017/Test_DB',function(err){
    if(err) return;
    console.log("succeed");
    Test.findOneAndUpdate({},{$inc:{count:1}}).exec(function(err,docs){
        console.log(docs)
    })
})
the output should be count : 1 but it's {count:0} ,but the data in database has updated to count:1
add: the original data is {count:0,_id:xxxx}