Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
作成されたドキュメントを取得するために別のクエリを作成することなく、作成されたドキュメントの ID を取得したいと考えています。ドキュメントを作成する前に、ドキュメントのIDを手動で作成する必要があると思います。これを行う方法はありますか?mongooseドライバーを使用しています。
mongoose
新しい mongoose モデル インスタンスを作成すると、その_id値は保存時の値にすでに設定されています。例えば:
_id
var user = new User(); // user._id is already set. ... user.save();