First you need to download the database, after installation, to find bin directory, opening the bin directory, copy the configuration to the current path environment variable
The bin and the same level, the need for a data / db folder, the folder and not automatically generated, must be manually set
Start the database to see 27017 instructions for starting a successful
mongod --dbpath e: \ data \ db
Enter the service
mongod
View mogod connection address
db.getMongo ()
Database operations
View database
show dbs
Create / switch databases
use the database name / use ttsf
View the database using the
db
View database details
db.stats ()
Delete the database
db.dropDatabase ()
Tables Operator
create a data table
db.createCollection ( 'table name')
View Data Sheet
db.getCollectionNames ()
Using a database and tables
db.getCollection ( 'table name')
By
db table .save. ({Key: val} )
Deleted
. Db table .remove ({key: val}) delete a one condition
. Db table .remove ({}) Delete all
Change
db table .update ({key: val}, {$ set: {key: val}}). The first value is the second value filter conditions are what need to be modified to modify the $ set
. Db table. update ({key: val}, {$ inc: {key: val}}) is a first value second value filter condition is modified to require modifying the digital inc is what $
Zha
. .Find db table () to check all
db table .find ({age: {$ gt : val}}). Greater than
db table .find. ({Age: {$ lt: val}}) is smaller than
db table name .find ({age: {$ gte : val}}) greater than or equal
db table .find ({age: {$ lte : val}}). less
db table .find ({age:. { $ gte: val, $ lte: between}}) intervals Val
DB table .find ({name:. / val /}) Fuzzy queries
. db table .find ({}, {key: 1, key: 0}) displays a query specifying field that is not displayed query column 0
db table .find () sort ({key: .. 1}) -1 sorted in ascending descending 1
.. db table .find () limit (n ) how many data
db. table .find (). skip (n) how many pieces of data to skip
db. table name .findOne () query a data
db. table name .find (). count () query the database has how many pieces of data
分页原理
/goods/pageGoods?limit=5&page=3;
let {limit,page}
db.students.find().spkip(0).limit(5)
db.students.find().spkip(5).limit(5)
db.students.find().spkip(10).limit(5)
db.students.find().spkip((page-1)*limit).limit(5)