mongoose .save() doesn't work

前端 未结 2 2304
走了就别回头了
走了就别回头了 2021-02-20 01:12

I have those code running try to save an object into MongoDB.

The .save() never got success run. the code runnin

2条回答
  •  悲哀的现实
    2021-02-20 01:48

    Please read this part of documentation from mongoose and try the following:

       var measure = new Cache({test:'teste'}); 
       // or measure.set('test', 'teste');
       measure.save(function (err) {
                        console.log(err);
                    });
    

    You will be able to see the issue if there's any.

    Update the issue is using:

    var Cache = conn.model('cache', cacheSchema);
    

    instead of

    var Cache = mongoose.model('cache', cacheSchema);
    

提交回复
热议问题