Hello fellow mongodb community,
I have two collections named installmentPromoUsers and installmentPromos . installmentPromoUsers collection stored data about users and the eligibility for each promo, here is the sample data
{
"_id": {
"$oid": "66a87013018edd61a7355042"
},
"cif": "1AH3CU",
"promotionIds": [
"SEGMENT_A_TEST",
"SEGMENT_B"
],
"usedInstallmentIds": []
}
installmentPromos collection stored information related to promotion details, here is the sample data
{
"_id": {
"$oid": "66a1c0854784fc46ec8727a2"
},
"installmentId": "RMDHN_3M",
"availableQuota": 3,
"expiryDate": {
"$date": "2025-08-07T08:19:21.000Z"
},
"interestRate": "1",
"minAmount": 500000,
"name": {
"en": "3 months",
"id": "3 bulan"
},
"normalRate": 21,
"promoTitle": {
"en": "Ramadhan Promo",
"id": "Promo Ramadhan"
},
"promotionId": "SEGMENT_A",
"quotaCustomer": 5,
"quotaTotal": 40,
"startDate": {
"$date": "2024-07-22T17:00:00.000Z"
},
"summary": {
"en": "- min. 500k\n- min 3 months",
"id": "- min. 500k\n- min 3 bulan"
},
"tenure": 3,
"termsAndConditions": {
"en": "- min. 500k\n- min 3 months",
"id": "- min. 500k\n- min 3 bulan"
},
"promotionName": "Ramadhan Promo"
}
In order to get the eligible promotions for particular user along with its detail , i need to join the two collection using aggregation lookup. Also, i need to perform aggregation with lookup and set to update availableQuota and usedInstallmentIds when user use the promotion. Let’s say, there are 5 parallel request to database, 3 of them are reading the date stored in collection installmentPromoUsers and installmentPromos, and 2 of them are updating the date stored in collection installmentPromoUsers and installmentPromos. The questions are :
- Does the mongodb block the read request of those 3 clients until the 2 clients finishes update data?
- Do i need certain locking mechanism to preserve data consistency for multiple read and write parallel requests?
Thank you