Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roll back invalid object creations not handled by realm.write() #6356

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update docs.
  • Loading branch information
elle-j committed Jan 5, 2024
commit c6c618de6abd4296399c7c908b43038d2748e952
4 changes: 3 additions & 1 deletion packages/realm/src/Realm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@ export class Realm {
}

// TODO: Support embedded objects
// TODO: Rollback by deleting the object if any property assignment fails (fixing #2638)
/**
* Create a new {@link RealmObject} of the given type and with the specified properties. For objects marked asymmetric,
* `undefined` is returned. The API for asymmetric objects is subject to changes in the future.
Expand Down Expand Up @@ -1152,6 +1151,9 @@ export class Realm {
* automatically. If any exception is thrown during the transaction {@link cancelTransaction} will
* be called instead of {@link commitTransaction} and the exception will be re-thrown to the caller of {@link write}.
*
* Note that if you choose to catch an exception within the callback and not rethrow it, the transaction
* will not be cancelled. However, the individual operation that failed will be rolled back automatically.
*
* Nested transactions (calling {@link write} within {@link write}) is not possible.
* @param callback - Function to be called inside a write transaction.
* @returns Returned value from the callback.
Expand Down