How to update a object in mongodb via mongoose?

后端 未结 2 1843
清歌不尽
清歌不尽 2021-02-12 15:34

I have mongoose schema as:

var Organization = new Schema({
  name: String,
  address: {
    street : String,
    city: String
  }
}, { collection: \'organization         


        
2条回答
  •  时光说笑
    2021-02-12 16:14

    Now you can update directly .

    OrganizationModel.update(
     {name: 'Koka'}, 
     {'address.street': 'new street name'}, 
     callback);
    

提交回复
热议问题