Skip to content

Instantly share code, notes, and snippets.

@heineiuo
Last active July 4, 2017 05:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heineiuo/969b66ae4324ed7cd7b27fe8b8453da5 to your computer and use it in GitHub Desktop.
Save heineiuo/969b66ae4324ed7cd7b27fe8b8453da5 to your computer and use it in GitHub Desktop.
get native `db` from mongoose
  1. 可以从Model里获取
const Users = mongoose.model('User', new mongoose.Schema({}), 'users')
const db = Users.db

// 然后就可以使用db了,比如 db.collection('users').find({}).toArray()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment