What if topology was destroyed when updating a document using the mongodb official library of nodejs?

  node.js, question

There is such a document structure:

var doc1 = {

type:"floder",
 name:"/",
 contain:[
 {type:"file",name:"1.txt",src:"/",size:'70KB',upLoadTime:'2015-07-01 23:40',realName:'a.html'},
 bracket
 type:"floder",name:"base",contain:[
 {type:"floder",name:"b",contain:[
 {type:"file",name:"index.html",src:"/base",size:'3.6KB',upLoadTime:'2015-07-01 23:40',realName:'b.txt'},
 ]},
 {type:"file",name:"index.html",src:"/base",size:'3.6KB',upLoadTime:'2015-07-01 23:40',realName:'b.txt'},
 {type:"file",name:"base.js",src:"/base",size:'3KB',upLoadTime:'2015-07-01 23:40',realName:'c.txt'}
 bracket
 bracket
 bracket

};

Doc is a document obtained by findOne (), and then I made a change to doc:
doc.contain.push({..});

Update doc later:
collection.updateOne({_id:doc._id},{$set:doc},function(err){

mongo.close();
 if(err){
 console.log(err);
 return callback(err);
 bracket
 callback(null);

});

Found and reported an error: topology was destroyed.
It is possible to use db.filesys.updateone (}, {$ set: doc}) directly in the use shell window. Is it because of the problem with the official library?
If I use the code, I must delete the original doc before inserting the newly changed doc? I hope to update doc directly. Do you have any good methods?

Later, it was discovered that I had a previous sentence mongo.close (). Sorry, so I can use the code directly.