Node + Mongoose: Get last inserted ID?

I want to retrieve the last inserted _id, using mongoose as MongoDB wrapper for node.js. I've found the following tutorial, but I can't change any node modules because the app runs on a public server:

Getting "Last Inserted ID" (hint - you have to hack Mongoose)

Any other ideas? This what I want to do:

  • Insert new user
  • Get user's _id value
  • Set a new session based on user's id
  • Redirect to /

Thanks!

16
задан Chris Fulstow 20 May 2011 в 23:42
поделиться