-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Major - P3
-
None
-
Affects Version/s: Q3-24FY
-
Component/s: Node.js, React Native, WASM
-
None
-
2 - S (<= 1 week)
-
5984
A previous PR provided an initial solution for how to apply UpdateMode to children when passed to Realm.create().
That solution uses a currentUpdateMode field on the Realm instance that's accessible by TypeHelpers.ts:
https://github.com/realm/realm-js/blob/5e2caccff9c805205939bb4932e77d44eb6748f8/packages/realm/src/TypeHelpers.ts#L265
Another option may be to have the toBinding() function accept the update mode on invocation (the aforementioned PR does allow for passing the update mode via the options argument as below, but it is unused):
https://github.com/realm/realm-js/blob/f7a280eb2bf0946755808fa5a94db3b836e4c143/packages/realm/src/TypeHelpers.ts#L267
However, this also presents certain issues:
- When a property of the Realm object is set (see code below), the toBinding() function is not called explicitly; but rather, it is called indirectly via the property type's setter:
- Setting the property:
https://github.com/realm/realm-js/blob/f7a280eb2bf0946755808fa5a94db3b836e4c143/packages/realm/src/Object.ts#L194-L196 - Triggers the call to toBinding() (renamed to itemToBinding() here):
https://github.com/realm/realm-js/blob/f7a280eb2bf0946755808fa5a94db3b836e4c143/packages/realm/src/PropertyHelpers.ts#L220-L221
- Setting the property:
Thus, we may want to look at various alternatives.