58

Transactions are coming to MongoDB 4.0

 6 years ago
source link: https://www.tuicool.com/articles/hit/IjiyEj
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Transactions are here…

MongoDB 4.0 (available today as a Release Candidate) adds support for multi-document transactions, making it the only database to combine the speed, flexibility, and power of the document model with ACID guarantees. Through snapshot isolation, transactions provide a consistent view of data, and enforce all-or-nothing execution to maintain data integrity. MongoDB 4.0 will be Generally Available in Summer 2018. 1

with client.start_session() as s:
    s.start_transaction()
    try:
        collection.insert_one(doc1, session=s)
        collection.insert_one(doc2, session=s)
        s.commit_transaction()
    except Exception:
        s.abort_transaction()

Python

Java


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK