Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
学ぶ Deleting Data | Section
Working with MongoDB in Express Applications

Deleting Data

メニューを表示するにはスワイプしてください

To remove data from MongoDB, you use methods provided by the model.

A common method is findByIdAndDelete.

app.delete('/users/:id', async (req, res) => {
  await User.findByIdAndDelete(req.params.id);

  res.send('user deleted');
});

The id is taken from the route parameter, and the matching document is removed from the database.

Example:

DELETE '/users/123': deletes user with id 123.

This allows your API to remove data when it is no longer needed.

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1. 章 10

AIに質問する

expand

AIに質問する

ChatGPT

何でも質問するか、提案された質問の1つを試してチャットを始めてください

Deleting Data

To remove data from MongoDB, you use methods provided by the model.

A common method is findByIdAndDelete.

app.delete('/users/:id', async (req, res) => {
  await User.findByIdAndDelete(req.params.id);

  res.send('user deleted');
});

The id is taken from the route parameter, and the matching document is removed from the database.

Example:

DELETE '/users/123': deletes user with id 123.

This allows your API to remove data when it is no longer needed.

すべて明確でしたか?

どのように改善できますか?

フィードバックありがとうございます!

セクション 1. 章 10
some-alt