MongoDB 删除记录

MongoDB 提供了 delete_one()delete_many() 来分别删除单条和多条记录:

pub async fn del(State(state): State<ArcAppState>, Path(id): Path<String>) -> Result<Json<u64>> {
    let n = state.note_collect().delete_one(doc! {"_id": &id}).await?;
    Ok(Json(n.deleted_count))
}
## 删除笔记
DELETE http://127.0.0.1:9527/d1198pkdrfaq966pf0ig
Content-Type: application/json
要查看完整内容,请先登录