Express and Mongodb

Today,I learn the Express frame and the Mongodb which is a noSQL database.

  1. If you want learn MongoDB, you should deploy MongoDB first! install,to select you computer system version. So I choose the Window Server 2008.
  2. Finish the download files, you should install
  3. when you finish installing,you need run command window ,in the Window system,cmd
  4. rember you should choose a disk to runmkdir data and mkdir log mkdir db in the data directory ,finally, cd logand touch mongodb.log;
    for me ,I choose the C disk to run command
  5. ok,run `mongod --dbpath "C:\data\db" --logpath "C:data\log\mongodb.log" --serviceName "MongoDB" --install
  6. run net start MongoDB //to start service . if you stop service ,run net stop MongoDB
  7. maybe you will meet trouble,like can't find net, so should add environment path to relative MongDB,to input C:\Program Files\MongoDB\Server\3.4\bin in the path option.
  8. now ,run mongo// this will show the connection success

Mongo Database

  • use [databaseName] insert dataBase
  • show dbs
  • show collections
  • show tables // delete db.collections.drop()
  • use [database name] to insert a database ,
  • db.runoob.insert({}); ---insert data
  • db.runoob.find()
  • db.runoob.update()
  • db.dropDatabse() -- to delete a database

waiting for updateing

Express

I advise to learn document of Express Chinese version

Update 📌11/25.2017

the command of the mongoDB


1. db.tablename.find().pretty()
2. db.tablename.stats;
3. var users=db.users;user.find().pretty();//can show the all record of db.users this table

the prototype of ObjectId is only.

var Id=new ObjectId();
Id //show some result 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。