MongoDB & Mongoose
Document modeling, aggregation, indexes, and consistency.
When do I need a transaction?
A transaction makes several database operations commit or roll back as a unit. MongoDB already makes single-document writes atomic, so a transaction is mainly needed when one business rule spans multiple documents. A session supplies transaction context; every participating operation must use that context.
Read concern vs write concern vs read preference?
Read concern, write concern and read preference control different parts of consistency and availability. Read concern controls which data a read may observe, write concern controls required acknowledgement, and read preference chooses eligible replica members. Combining them deliberately matters when an application expects to read a recent write or survive failover.
Replication vs sharding: what is the difference?
Replication keeps copies of data so a system can recover from node failure, while sharding distributes different subsets of data across nodes. Replica sets improve redundancy; sharding spreads storage and workload. A sharded deployment can also replicate each shard, so these techniques are complementary.
Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.