mongo_action
https://docs.mongodb.com/manual/introduction/
{
name: "sue",
age: 3,
status: "A",
groups: ["news", "sports"]
}
添加字段
db.Analyse_user.updateMany(
{},
{$set: {clue_area:[],clue_category:[]}}
);
> db.auth("pyspark_admin","admin123");
1
> show collections
mt0
> help
db.help() help on db methods
db.mycoll.help() help on collection methods
sh.help() sharding helpers
rs.help() replica set helpers
help admin administrative help
help connect connecting to a db help
help keys key shortcuts
help misc misc things to know
help mr mapreduce
show dbs show database names
show collections show collections in current database
show users show users in current database
show profile show most recent system.profile entries with time >= 1ms
show logs show the accessible logger names
show log [name] prints out the last segment of log in memory, 'global' is default
use <db_name> set current database
db.foo.find() list objects in collection foo
db.foo.find( { a : 1 } ) list objects in foo where a == 1
it result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
exit quit the mongo shell
> db.help()
DB methods:
db.adminCommand(nameOrDocument) - switches to 'admin' db, and runs command [ just calls db.runCommand(...) ]
db.auth(username, password)
db.cloneDatabase(fromhost)
db.commandHelp(name) returns the help for the command
db.copyDatabase(fromdb, todb, fromhost)
db.createCollection(name, { size : ..., capped : ..., max : ... } )
db.createView(name, viewOn, [ { $operator: {...}}, ... ], { viewOptions } )
db.createUser(userDocument)
db.currentOp() displays currently executing operations in the db
db.dropDatabase()
db.eval() - deprecated
db.fsyncLock() flush data to disk and lock server for backups
db.fsyncUnlock() unlocks server following a db.fsyncLock()
db.getCollection(cname) same as db['cname'] or db.cname
db.getCollectionInfos([filter]) - returns a list that contains the names and options of the db's collections
db.getCollectionNames()
db.getLastError() - just returns the err msg string
db.getLastErrorObj() - return full status object
db.getLogComponents()
db.getMongo() get the server connection object
db.getMongo().setSlaveOk() allow queries on a replication slave server
db.getName()
db.getPrevError()
db.getProfilingLevel() - deprecated
db.getProfilingStatus() - returns if profiling is on and slow threshold
db.getReplicationInfo()
db.getSiblingDB(name) get the db at the same server as this one
db.getWriteConcern() - returns the write concern used for any operations on this db, inherited from server object if set
db.hostInfo() get details about the server's host
db.isMaster() check replica primary status
db.killOp(opid) kills the current operation in the db
db.listCommands() lists all the db commands
db.loadServerScripts() loads all the scripts in db.system.js
db.logout()
db.printCollectionStats()
db.printReplicationInfo()
db.printShardingStatus()
db.printSlaveReplicationInfo()
db.dropUser(username)
db.repairDatabase()
db.resetError()
db.runCommand(cmdObj) run a database command. if cmdObj is a string, turns it into { cmdObj : 1 }
db.serverStatus()
db.setLogLevel(level,<component>)
db.setProfilingLevel(level,<slowms>) 0=off 1=slow 2=all
db.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the db
db.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the db
db.setVerboseShell(flag) display extra information in shell output
db.shutdownServer()
db.stats()
db.version() current version of the server
> db.collection.help()
DBCollection help
db.collection.find().help() - show DBCursor help
db.collection.bulkWrite( operations, <optional params> ) - bulk execute write operations, optional parameters are: w, wtimeout, j
db.collection.count( query = {}, <optional params> ) - count the number of documents that matches the query, optional parameters are: limit, skip, hint, maxTimeMS
db.collection.copyTo(newColl) - duplicates collection by copying all documents to newColl; no indexes are copied.
db.collection.convertToCapped(maxBytes) - calls {convertToCapped:'collection', size:maxBytes}} command
db.collection.createIndex(keypattern[,options])
db.collection.createIndexes([keypatterns], <options>)
db.collection.dataSize()
db.collection.deleteOne( filter, <optional params> ) - delete first matching document, optional parameters are: w, wtimeout, j
db.collection.deleteMany( filter, <optional params> ) - delete all matching documents, optional parameters are: w, wtimeout, j
db.collection.distinct( key, query, <optional params> ) - e.g. db.collection.distinct( 'x' ), optional parameters are: maxTimeMS
db.collection.drop() drop the collection
db.collection.dropIndex(index) - e.g. db.collection.dropIndex( "indexName" ) or db.collection.dropIndex( { "indexKey" : 1 } )
db.collection.dropIndexes()
db.collection.ensureIndex(keypattern[,options]) - DEPRECATED, use createIndex() instead
db.collection.explain().help() - show explain help
db.collection.reIndex()
db.collection.find([query],[fields]) - query is an optional query filter. fields is optional set of fields to return.
e.g. db.collection.find( {x:77} , {name:1, x:1} )
db.collection.find(...).count()
db.collection.find(...).limit(n)
db.collection.find(...).skip(n)
db.collection.find(...).sort(...)
db.collection.findOne([query], [fields], [options], [readConcern])
db.collection.findOneAndDelete( filter, <optional params> ) - delete first matching document, optional parameters are: projection, sort, maxTimeMS
db.collection.findOneAndReplace( filter, replacement, <optional params> ) - replace first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.collection.findOneAndUpdate( filter, update, <optional params> ) - update first matching document, optional parameters are: projection, sort, maxTimeMS, upsert, returnNewDocument
db.collection.getDB() get DB object associated with collection
db.collection.getPlanCache() get query plan cache associated with collection
db.collection.getIndexes()
db.collection.group( { key : ..., initial: ..., reduce : ...[, cond: ...] } )
db.collection.insert(obj)
db.collection.insertOne( obj, <optional params> ) - insert a document, optional parameters are: w, wtimeout, j
db.collection.insertMany( [objects], <optional params> ) - insert multiple documents, optional parameters are: w, wtimeout, j
db.collection.mapReduce( mapFunction , reduceFunction , <optional params> )
db.collection.aggregate( [pipeline], <optional params> ) - performs an aggregation on a collection; returns a cursor
db.collection.remove(query)
db.collection.replaceOne( filter, replacement, <optional params> ) - replace the first matching document, optional parameters are: upsert, w, wtimeout, j
db.collection.renameCollection( newName , <dropTarget> ) renames the collection.
db.collection.runCommand( name , <options> ) runs a db command with the given name where the first param is the collection name
db.collection.save(obj)
db.collection.stats({scale: N, indexDetails: true/false, indexDetailsKey: <index key>, indexDetailsName: <index name>})
db.collection.storageSize() - includes free space allocated to this collection
db.collection.totalIndexSize() - size in bytes of all the indexes
db.collection.totalSize() - storage allocated for all data and indexes
db.collection.update( query, object[, upsert_bool, multi_bool] ) - instead of two flags, you can pass an object with fields: upsert, multi
db.collection.updateOne( filter, update, <optional params> ) - update the first matching document, optional parameters are: upsert, w, wtimeout, j
db.collection.updateMany( filter, update, <optional params> ) - update all matching documents, optional parameters are: upsert, w, wtimeout, j
db.collection.validate( <full> ) - SLOW
db.collection.getShardVersion() - only for use with sharding
db.collection.getShardDistribution() - prints statistics about data distribution in the cluster
db.collection.getSplitKeysForChunks( <maxChunkSize> ) - calculates split points over all chunks and returns splitter function
db.collection.getWriteConcern() - returns the write concern used for any operations on this collection, inherited from server/db if set
db.collection.setWriteConcern( <write concern doc> ) - sets the write concern for writes to the collection
db.collection.unsetWriteConcern( <write concern doc> ) - unsets the write concern for writes to the collection
db.collection.latencyStats() - display operation latency histograms for this collection
use hbase
db.hbase.insertOne(
{ item: "canvas", qty: 100, tags: ["cotton"], size: { h: 28, w: 35.5, uom: "cm" } }
)
db.createUser(
{
user: "hbaseU",
pwd: "123",
roles: [
{ role: "readWrite", db: "hbase" }
]
}
)
mongo_action的更多相关文章
随机推荐
- Spring容器AOP的理解
一句话理解:根据被代理对象信息通过Proxy动态生成我们具体的代理类. 实现就动态代理.那动态代理是什么呢? 动态代理其实并不是什么新鲜的东西,学过设计模式的人都应该知道代理模式,代理模式就是一种静态 ...
- 如何在LSI MegaRAID BIOS里设定RAID 10与Hot Spare
1. 同时按下 ”Ctrl + H” 进入MegaRAID WebBIOS 画面,可以看到所有物理硬盘 (Physical Drives) 的信息.请在左边视窗点选“Configuration Wiz ...
- [Shell] Backtick vs $() 两种方式内嵌值
使用反撇号(重音符)`command` 和 $(command) 都表示内嵌shell命令. for file in $(ls); do echo $file done for file in `ls ...
- linux 开机自启
cd /home/dpf 1.vi startup.sh #!/bin/shecho "hello world" >> /home/dpf/test.txt vi mq ...
- CDN的那些细枝末节
起源: 原本打算系统看看关于axios的介绍,无意中就看见一句"Using cdn",于是百度一下,"cdn"是什么? 名词解释:CDN CDN的全称是Cont ...
- DOM的学习
今天学习了DOM,感觉学习起来真的没那么简单啦,这不是一个好现象啊,只有依靠自己大补课,嘿嘿,具体的总结了一下,今天学习的其实并不多,仅仅学习了不同的节点类型,但是知识还是蛮碎的,要一点一点的总结,昨 ...
- .Net学习心得
把握自己就是,就是时时拥一颗清澈的心,拥有一片明朗的情怀,缓缓地,从2014的国度里跨进了2015,而我们也就随之告别了2个月的学习之旅,在这里我们拥有了如白色漂渺的梦,黯然升起,在彩色的云霄里飘 ...
- php获取ios或android通过文件头(header)传过来的坐标,通过百度接口获取具体城市和地址,并存入到session中。
首先,在function.php方法文件中封装一个获取header头文件的方法. if (!function_exists('getallheaders')) { function getallhea ...
- 【架构师之路】Nginx负载均衡与反向代理—《亿级流量网站架构核心技术》
本篇摘自<亿级流量网站架构核心技术>第二章 Nginx负载均衡与反向代理 部分内容. 当我们的应用单实例不能支撑用户请求时,此时就需要扩容,从一台服务器扩容到两台.几十台.几百台.然而,用 ...
- 【Linux】 centos 7 启用端口
网上的大部分资料都是用iptables防火墙的,但是阿里云的centos 7默认防火墙是firewall.最为简单的方法其实就是关闭我们的防火墙: 1 查看下防火墙的状态: systemctl st ...