zoukankan      html  css  js  c++  java
  • 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" }
    ]
    }
    )

  • 相关阅读:
    Element-UI饿了么时间组件控件按月份周日期,开始时间结束时间范围限制参数
    揭秘(爱奇艺、优酷、腾讯)在线视频网站视频2倍速、多倍速快速播放的前端实现方法
    提高敲代码的效率:程序员同扭曲时间的事儿抗争
    原生JS在网页上复制的所有文字后面自动加上一段版权声明
    .net core kafka 入门实例 一篇看懂
    聊聊Grpc使用中的坑以及怎么填
    MongoDB 上手开发实践(入门上手就这一篇)
    聊聊redis实际运用及骚操作
    .NET Core 微服务之Polly熔断策略
    .NET Core 微服务之Polly重试策略
  • 原文地址:https://www.cnblogs.com/rsapaper/p/5860412.html
Copyright © 2011-2022 走看看