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的更多相关文章
随机推荐
- 个人成长|荣获CNVD年度最有价值漏洞奖
本文共750+字,预计阅读2-3分钟. 前几天,很荣幸受主办方邀请,还拿了CNVD的一个“年度最有价值漏洞奖”,说一说,这几天的故事吧. 11月20号,意外收到一个会议邀请,当时还比较诧异,印象中我在 ...
- 【RF库XML测试】测试的XML文件说明
文件存放路径:C:\workspace\robotframework\test_rf_api\testdata\XML.xml 文件内容: <example> <first id=& ...
- 【RF库Collections测试】Keep In Dictionary
Name:Keep In DictionarySource:Collections <test library>Arguments:[ dictionary | *keys ]Keeps ...
- Splash 简介与安装
Splash 说白了就是一个轻量级的浏览器,利用它,我们同样可以实现跟其他浏览器一样的操作,我们使用 Docker 来安装 Splash: [root@localhost ~]# docker run ...
- es5.0 安装ik中文分词器 mac
es5.0集成ik中文分词器,网上资料很多,但是讲的有点乱,有的方法甚至不能正常运行此插件 特别注意的而是,es的版本一定要和ik插件的版本相对应: 1,下载ik 插件: https://github ...
- js当中null和{}区别
{}是一个不完全空的对象,因为他的原型链上还有Object呢,而null就是完全空的对象,啥也没有,原型链也没有,所以null instanceof Object === false;[]就更不用说了 ...
- iOS提交审核:您的 App 正在使用广告标识符 (IDFA)
本文转载至 https://mp.weixin.qq.com/s?__biz=MzA3NzM0NzkxMQ==&mid=401172721&idx=1&sn=a369cf1b ...
- C# - 获取类中属性的名称
用反射控制的,不过获取属性名称的方法,用方法形式获取的,不知道消耗大不大 using System; using System.Collections.Generic; using System.Li ...
- 删除SQL注入的一些方法总结
sql替换法: ); set @myStr='oa_20121026new.bak</title><style>.alx2{position:absolute;clip:rec ...
- 三、K3 WISE 开发插件《K3 WISE开发手册》
1.VB插件工程的命名.命名空间和生成的DLL命名要一致,否则导致注册不成功! 2.主控台的查询分析工具,添加sql直接报表,代码用到临时表,提示“在对应所需名称或序数的集合中未找到项目” 解决:在代 ...