Js connected using the method
var mgs=requrie('mongoose')
// introduced mongoose module
var url='mongoose://127.0.0.1:27017/member'
// create mango database, library named member
msg.connect(url)
// url database connection
mgs.connection.on('connected',function(){console.log('CONNECT')})
// Check whether the connection, if already connected (Connected), the console output 'CONNECT'
var type={name:String,grade:String,txt:String}
// type mapping, name, grade, txt types are string
var users=mgs.model('user',mgs.Schema(type));
// definition of the list and is connected to the database
module.exports=users2
// export the database
mongoose and mongodb difference:
mongoose is mongodb for convenient operation in an asynchronous environment node.js tool object model is an object model library for mongoDB operation, the package of the mongoDB document, or the like CRUD
mongodb is based on a distributed file storage document database, the range of products between relational databases and non-relational databases, the biggest feature is that he is very powerful query language supported, but also support for data indexing