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 

你可能感兴趣的:(Express and Mongodb)