Skip to content

Commit

Permalink
Updated mongo instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Jun 12, 2020
1 parent a701242 commit 1268ec3
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mongodb.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
MongoDB
=======

Replication::

# run minimum 3 mongo nodes
# execute next command on the one node
rs.initiate({_id: "rs1", members: [{_id: 0, host: "mongo1:27017" }, {_id: 1, host: "mongo2:27017"}, {_id: 2, host: "mongo3:27017"}]});

# check conf
rs.conf()

# check status
rs.status()

# allow queries from secondary (applied for current session)
rs.slaveOk()


Insert values::

db.<collection>.insertMany([
{ item: "journal", qty: 25, status: "A", size: { h: 14, w: 21, uom: "cm" }, tags: [ "blank", "red" ] },
{ item: "notebook", qty: 50, status: "A", size: { h: 8.5, w: 11, uom: "in" }, tags: [ "red", "blank" ] }
]);


Execute JS code::

Expand Down Expand Up @@ -36,6 +59,8 @@ Print a list of all collections for current database::
show collections
# or
db.getCollectionNames()
# or
show tables


Print documents of collection::
Expand Down

0 comments on commit 1268ec3

Please sign in to comment.