---
# System prepended metadata

title: MONGODB 2019-10-18

---

MONGODB 2019-10-18
===
STOCK: `NASDAO:MDB`

Summary
---
1. Replica Set command `rs.{command}`.
2. Sharded Cluster command `mongos`.

Morning (Basic)
--- 
### Replica Set

1. Node number must better on odd.
2. Node Priority and hidden. 
    - `hidden: true` means this node only for backup use, no election use.
    - `priority: 0`  means this node only for election, wont be primary. `arbiter`
3. use `db.insert` Configuration, `{..., WriteConcern: {w: 2} }` to ensure that db was write on replica, before response.
4. use `db.readConcern` Configuration need to be set, for ensure won't dirty read, or not latest data.
5. use `db.readPreference` Configuration, to mongodb get data from `primary` or `secondary` or `preferred`.


#### Common Use Command
1. `add( [string] )`: Add node to Replicate
2. `stepDown()`: Restart Current Master.


AfterNoon (Advance)
---
Agenda
1. Overview of What's New in 4.2
2. Transactions
3. Complex Queries & Analysis
4. Resilience
5. Security
6. Deployment Options

### MongoDB 4.2 New Features
1. Distrubuted Transaction (Sharded Cluster)
2. Allow to Encrypt specific column

### Multi-Document ACID Transaction
1. Basic Transaction 2 years ago.

### Complex Queries & Analysis
1. On-Demand Material View
    -  Performance hard to optimized.
    -  Usage: Use to calculate data aggreagate (sum/average) result.
    -  Create By aggregate `$merge`.
2. WildCard Indexes
    -  No need to specific selected column
3. Other Query Enchancement
    -  Allow expression on query.
4. New Aggregationn Operator
    - Trigonometry Expressions
    - Round RExpressions
    - $$Now
    - Regex

### MongoDB COnnector for Apache Kafka(Beta)
Apache Kafka -> MongoDB -> Apache Kafka

### Resilience
1. Retryable Reads & Writes
    - Mongodb Auto Retry Reads & Writes when query had crashed.

### Security

![](https://i.imgur.com/wwe6jue.jpg =500x)

1. Mongodb can specific a column to encrypted.


Tools
---
1. MongoDB Compass (Totally Free in 2019 Oct 18)
2. MongoDB Cloud Data Lake Connect S3
3. MongoDB Enterprise Operator for Kubernetes
4. 
