Get the App
SLTechnology News&Howtos  ›  Database  › 

Daily work of Mongo

Shulou Source: shulou.com Published: 2022-06-01 22:19:16 10月04日 Update

Mongo login:

. / mongo ip:port/lych-lych is dbname-use lych,db,show collections

Db.auth ("rds", "abc123")-abc123 is passwd

Db.collection.find ()

{field1:, field2:...}

Db.collection.update ()

(,-query: update query condition, similar to sql update query where condition.

The object of update and some updated operators (such as $, $inc...), etc., can be understood as set in sqlplus

{upsert:,-if there is no record of update, whether to insert objNew, (true,false:

Do not insert by default)

Multi:,-mongodb defaults to false. Only the first record found will be updated. If this parameter is true, multiple records will be updated according to the condition.

WriteConcern:})-optional, the level at which the exception is thrown

Db.abc.update ({"ipad": "/ ^ 12.80 /"}, {$set: {"code": 6000}}, {muti:true})-"ipad": / 12.80 $/ ends with 12.80

Db.collection.remove ()

Db.abc.remove ({"ipad": "/ ^ 12.80 /"})

Mongoexport

. / mongoexport-h ip:port-d rds-u lych-c lych-o lych.dat

. / mongoimport-h ip:port-d rds-u lych-c lych lych.dat

-the document will then be refined for each content.

Sometimes it is easy to report an error when the spliced insert script is placed in the foreground, but it is normal to put the js file for import:

. / mongo ip:port/rds-u lych-p lych000 hic.js

Tags: Conditions updates queries content foreground parameters multiple objects operators files documents levels scripts login daily work work Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Information Microsoft macOS Apple