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.
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?
"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.
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.
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.
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 ?
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?
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?
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 < < < then I would think we still have double book problem but the check is still OK 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?
✅ Sign-up for a free cluster at: mdb.link/free-bdS03tgD2QQ
✅ Get help on our Community Forums: mdb.link/community-bdS03tgD2QQ
Super awesome and straightforward explanation! Great work👍
superb content, easy to understand
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.
I love this video. Thanks Lauren
well it would be easier just to do
reservation = {
...reservation,
...reservationDetails,
}
Absolutely Awesome video infinite ❤️❤️❤️...
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?
Yes. Exactly.
very well explained. thanks!
inside catch always use console.error, to send message to correct stream
i have a few questions no 1: what is the difference between $push and $addToSet array operator? couldn't we use $push instead?
"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.
The session details are stored at the application level. What happens if the application server crashes mid-transaction?
Good question. Interested as well please.
you are the best!! :)
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.
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.
tnks very useful
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 ?
is the procedure for converting standalon mogodb to replica set same if i am using mongodb as a service ?
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?
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?
Thanks.
3: can we use $each operator to add an object to a subdocument?
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 < < < then I would think we still have double book problem but the check is still OK
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?
Ok, I've got it. the reservationDates is an Array listing all Dates (not a period fromDate to toDate as I assumed).
nice specks
Amazing tutorials. Also you have, like, super duper nice teeth lol
Page doesn't exists
Why do you need Node.js? Can't it be done in terminal?