2024年4月15日发(作者:)

> ()

{ "_id" : 1, "name" : "oppoR11", "price" : "3000" }

1.9 删除表 ();

> show collections

goods

user

> ();

true

> show collections;

user

>

2.0 删除数据库

tabase()

> show dbs;

admin 0.000GB

config 0.000GB

local 0.000GB

shop 0.000GB

> use shop;

switched to db shop

> tabase();

{ "dropped" : "shop", "ok" : 1 }

> show dbs;

admin 0.000GB

config 0.000GB

local 0.000GB

>

2.1 查询帮助 ();

> ()

DB methods:

ommand(nameOrDocument) - switches to 'admin' db, and runs command [just calls mand(...)]

ate([pipeline], {options}) - performs a collectionless aggregation on this database; returns a cursor

(username, password)

atabase(fromhost) - deprecated

dHelp(name) returns the help for the command

tabase(fromdb, todb, fromhost) - deprecated

Collection(name, {size: ..., capped: ..., max: ...})

View(name, viewOn, [{$operator: {...}}, ...], {viewOptions})

User(userDocument)

tOp() displays currently executing operations in the db

tabase()

() - deprecated

ock() flush data to disk and lock server for backups

nlock() unlocks server following a ock()

lection(cname) same as db['cname'] or

lectionInfos([filter]) - returns a list that contains the names and options of the db's collections

lectionNames()

tError() - just returns the err msg string

tErrorObj() - return full status object

Components()

go() get the server connection object

go().setSlaveOk() allow queries on a replication slave server

e()

vError()

filingLevel() - deprecated

filingStatus() - returns if profiling is on and slow threshold

licationInfo()

lingDB(name) get the db at the same server as this one

teConcern() - returns the write concern used for any operations on this db, inherited from server object if set

fo() get details about the server's host

er() check replica primary status

(opid) kills the current operation in the db

mmands() lists all the db commands

rverScripts() loads all the scripts in

()

ollectionStats()

eplicationInfo()

hardingStatus()

laveReplicationInfo()

er(username)

Database()

rror()

mand(cmdObj) run a database command. if cmdObj is a string, turns it into {cmdObj: 1}

Status()

Level(level,)

filingLevel(level,slowms) 0=off 1=slow 2=all

teConcern() - sets the write concern for writes to the db

riteConcern() - unsets the write concern for writes to the db

boseShell(flag) display extra information in shell output

wnServer()

()

n() current version of the server