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的更多相关文章

随机推荐

  1. 通过SSH实现Windows与linux之间传输文件

    Linux是非常好的开发环境,但很多时候我们希望能够在Windows上操作,通过SSH协议可以实现两者之间传输文件. 一 需要在Linux系统上安装ssh-server,有的linux系统自带了. 查 ...

  2. 7代CPU安装win7的方法

    7代CPU安装win7会遇到的问题: 32位的win7不支持uefi启动,64位win7理论上支持uefi启动,但实际上需要开启兼容模式才能启动,并且启动速度并没有变快. 根据不同型号的主板,需要解决 ...

  3. iOS开发-为UITableViewCell添加横线

    在开发过程中经常会遇到设计稿中Cell分割线样式和系统自带的样式差别很大,如何实现这里做下总结,主要包括如下两步: 1. 取消TableView默认的分割线样式 _tableView.separato ...

  4. python中的数据类型与json的数据类型之间的转化

    什么是json: JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programm ...

  5. ISD9160学习笔记03_ISD9160音频解码代码分析

    录音例程涉及了录音和播放两大块内容,这篇笔记就先来说说播放,暂且先击破解码这部分功能. 我的锤子便签中有上个月记下的一句话,“斯蒂芬·平克说,写作之难,在于把网状思考,用树状结构,体现在线性展开的语句 ...

  6. Java的Integer和int有什么区别

    Java是面向对象的编程语言,一切都是对象,但是为了编程的方便还是引入了基本数据类型,为了能够将这些基本数据类型当成对象操作,Java为每一个基本数据类型都引入了对应的包装类型(wrapper cla ...

  7. C语言EOF是什么?

    C语言 EOF是什么? Linux中,在新的一行的开头,按下Ctrl-D,就代表EOF(如果在一行的中间按下Ctrl-D,则表示输出"标准输入"的缓存区,所以这时必须按两次Ctrl ...

  8. 【linux系列】centos7配置桥接模式静态IP

    一.设置桥接模式 VMware->Edit->Virtual Network Edit 二.查看物理机的ip地址 三.根据物理机的ip地址,设置linux虚拟机的ip地址 四.网络重启 五 ...

  9. Webpack 备忘录

    Webpack 属于在项目中配置一次就很少改动的那种工具,但这样就导致新项目再配置 Webpack 时会有些生疏,所以将 Webpack 核心概念及常用配置记录如下. 1)核心概念 Webpack 4 ...

  10. C语言工具:LCC-Win32+v3.0

    LCC-Win32+v3.0(带汉化).rar  小巧精悍的工具 安装步骤: 1.先安装 LCC-Win32V3.0.exe 假如安装目录为:C:\lcc 2.再安装 LCC-Win32V3.0汉化补 ...