-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
1 - XS (<= 1 day)
-
3966
-
Not Needed
Problem
When an object is not found with objectForPrimaryKey, undefined is returned. This is syntactically not correct. It should return a null value, since the object does not exist. undefined should be reserved for unset properties.
Solution
Change the implementation of objectForPrimaryKey to return null.
Update the types as follows:
objectForPrimaryKey<T>(type: string, key: Realm.PrimaryKey): (T & Realm.Object) | null; objectForPrimaryKey<T extends Realm.Object>(type: {new(...arg: any[]): T; }, key: Realm.PrimaryKey): T | null;
How important is this improvement for you?
I'd like to see it, but have a workaround