MongoDB & Node.js: Create an ACID Transaction (Part 3 of 4)

Ғылым және технология

✅ Sign-up for a free cluster at: mdb.link/free-bdS03tgD2QQ
✅ Get help on our Community Forums: mdb.link/community-bdS03tgD2QQ
In part three of this quick start tutorial for developers, Lauren Schaefer explains how to create ACID (atomicity, consistency, isolation, durability) transactions for MongoDB in a Node.js script. She explains how to use withTransaction() and a session to successfully complete or abort a transaction.
Chapters:
00:00 Intro
01:06 ACID transactions in MongoDB
04:06 The Setup
05:19 Create a Transaction
05:43 Create a Helper Function
07:50 Create a Function for the Transaction
17:59 Call the Function
20:54 Wrapping Up
Other videos in this tutorial series:
Part 1: • MongoDB & Node.js: Con...
Part 2: • MongoDB & Node.js: Agg...
Links Lauren mentions in the video:
Lauren's blog post: How to Use MongoDB Transactions in Node.js developer.mongodb.com/quickst...
Lauren's GitHub repo with the code from this video github.com/mongodb-developer/...
Lauren's script to create a "users" collection github.com/mongodb-developer/...
Node.js & MongoDB Starter Template File github.com/mongodb-developer/...
MongoDB Documentation: Convert a Standalone to a Replica Set docs.mongodb.com/manual/tutor...
Connect with Lauren:
Twitter: / lauren_schaefer​
TikTok: / lauren_schaefer​
Linkedin: / laurenjan...​
MongoDB Community: developer.mongodb.com/communi...
Subscribe to MongoDB ►►► bit.ly/3bpg1Z1
Connect with MongoDB:
Website: bit.ly/2LjtNBZ
Twitter: bit.ly/3fH87gR
Facebook: bit.ly/3fEaIsd
Linkedin: bit.ly/2SY9w90
Instagram: bit.ly/3bn9bDv
Community Forums: bit.ly/2I8VCi5
TikTok: bit.ly/3fHoqdJ

Пікірлер: 32

  • @MongoDB
    @MongoDB10 ай бұрын

    ✅ Sign-up for a free cluster at: mdb.link/free-bdS03tgD2QQ ✅ Get help on our Community Forums: mdb.link/community-bdS03tgD2QQ

  • @roaring_cannon
    @roaring_cannon3 жыл бұрын

    Super awesome and straightforward explanation! Great work👍

  • @sanjitselvan5348
    @sanjitselvan53482 жыл бұрын

    very well explained. thanks!

  • @olaleyeemmanuel1492
    @olaleyeemmanuel1492 Жыл бұрын

    I love this video. Thanks Lauren

  • @vimukthaariyasinghe8041
    @vimukthaariyasinghe80418 ай бұрын

    superb content, easy to understand

  • @upendrasingh6451
    @upendrasingh6451 Жыл бұрын

    Absolutely Awesome video infinite ❤️❤️❤️...

  • @ayanSaha13291
    @ayanSaha13291 Жыл бұрын

    Transactions are needed to avoid concurrent modification related issues like read skew, phantom read, lost updates etc. Single threaded applications or where two transactions are accessible not-shared data are not prone to these errors, hence won't benefit from transactional overhead. We see a Single threaded usage of a transactions in the example which particularly does not solve any problems. Would you like to shed some light on what kinds of transaction Isolation it is using or we have options to use in Mongo. It would be really helpful to understand the transactional guarantees Mongo dB currently provides.

  • @aram5642
    @aram56422 жыл бұрын

    If I extended a schema with a custom method, which is usually a part of an outer transaction, is it a safe practice to pass session parameter to that method?

  • @eduardocaldera6914
    @eduardocaldera69143 жыл бұрын

    you are the best!! :)

  • @noorulamin2652
    @noorulamin26523 жыл бұрын

    2: in current case datesReserved is an array of only dates right? suppose if this array was a Subdocument we know the $in operator won't work . So in such situation which operator would we use to find a particular sub document in a collection ?

  • @siddharthsvnit
    @siddharthsvnit2 жыл бұрын

    is the procedure for converting standalon mogodb to replica set same if i am using mongodb as a service ?

  • @blackjamiyanduurenjargal
    @blackjamiyanduurenjargal6 ай бұрын

    tnks very useful

  • @noorulamin2652
    @noorulamin26523 жыл бұрын

    3: can we use $each operator to add an object to a subdocument?

  • @jaggyjut
    @jaggyjut2 жыл бұрын

    I get an error: The transaction was aborted due to an unexpected error: MongoServerError: The dollar ($) prefixed field '$date' in 'datesReserved.0.$date' is not valid for storage.

  • @weinschelbarretto3263
    @weinschelbarretto32632 жыл бұрын

    How would one go about maintaining a transaction for nested function calls? Like say for example a function A has some code in it and also calls function B. Now we can use session.withTransaction() in function A, but how do we use this same transaction for the database operations in function B? Do we pass the session variable as an argument to function B and use it in there?

  • @razbuchnik6007

    @razbuchnik6007

    Жыл бұрын

    Yes. Exactly.

  • @ashishkumari762
    @ashishkumari7629 ай бұрын

    Thanks.

  • @noorulamin2652
    @noorulamin26523 жыл бұрын

    i have a few questions no 1: what is the difference between $push and $addToSet array operator? couldn't we use $push instead?

  • @mohammedsadiq1567

    @mohammedsadiq1567

    2 жыл бұрын

    "addToSet" works just like it sounds - a *SET* It looks for duplicate entry. If the item already exists in the array, it doesn't do anything. If the item doesn't exist in the array, then it is added. With $push, it will add duplicate item.

  • @ajengmaharriza9354
    @ajengmaharriza93543 жыл бұрын

    inside catch always use console.error, to send message to correct stream

  • @adityadalal3486
    @adityadalal3486 Жыл бұрын

    The session details are stored at the application level. What happens if the application server crashes mid-transaction?

  • @razbuchnik6007

    @razbuchnik6007

    Жыл бұрын

    Good question. Interested as well please.

  • @ajengmaharriza9354
    @ajengmaharriza93543 жыл бұрын

    well it would be easier just to do reservation = { ...reservation, ...reservationDetails, }

  • @sylveredge1237
    @sylveredge12372 жыл бұрын

    I realy enjoyed first two tutorials, but this one definitely did not feel like quick start video. The example was so complicated, that for me, someone completely new to MongoDB, i got so lost in the complexity of the example, that i barely grasped how transactions work. Just replicating code without having any clue what i was doing. I would much prefer very simple example focused more on explaining how everything works for a "quick start" series. Previous videos were great tho and easy to understand.

  • @thanghwang2208
    @thanghwang2208 Жыл бұрын

    I am new and I have a question @13:04 Author uses “datesReserved:{$in: reservationDates}” According to documentation the $in operator will look for documents where “value of a field equals any value in the specified array”. If datesReserved=[,], reservationDates=[,] and Another word does $in operator (1)checks for the range of time or it (2)checks for the individual time value of the conditional array? I would think (2) is the case according to the above documentation definition?

  • @thanghwang2208

    @thanghwang2208

    Жыл бұрын

    Ok, I've got it. the reservationDates is an Array listing all Dates (not a period fromDate to toDate as I assumed).

  • @himanshupandey3451
    @himanshupandey3451 Жыл бұрын

    nice specks

  • @yogiHalim
    @yogiHalimАй бұрын

    I think the meaning of transaction is not described here? Is it editing two tables (collections) in one function? Why is it need to be emphasized that it is supported, isn't it common to be able to edit / work on multible tables?

  • @withpikachu2402
    @withpikachu24023 жыл бұрын

    Why do you need Node.js? Can't it be done in terminal?

  • @warlax5658
    @warlax56582 жыл бұрын

    Amazing tutorials. Also you have, like, super duper nice teeth lol

  • @sami-pl
    @sami-pl Жыл бұрын

    Page doesn't exists

Келесі