-
Notifications
You must be signed in to change notification settings - Fork 585
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
JSON serialization of Realm.Object & Realm.Collection (incl. polished TS declarations) #3044
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the PR is good. with some comments. Good job 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! This is a minor suggestion to only call toJSON when we hit one of our own Collection / Object types.
I'll be moving this forward while Steffen is 🍹 🏖️ |
dad9080
to
e896325
Compare
e896325
to
4458651
Compare
…to ensure object references.
…hen using Realm.JsonSerializationReplacer & added.
…or circular references in JSON serialization.
… underlying behavior.
…lizarion test updated to test both.
…optional props of Realm.List<T> in the form of Array<T>.
…lm.Objects with primary keys. (#3053)
47842da
to
f904701
Compare
correct me if I'm wrong, but I think this makes the type-checking too strict when you're updating a record using
TypeScript will throw an error saying |
@hudon I suspect you're right - and thanks for the example. |
JSON serialization of
Realm.Object
&Realm.Collection
& a rework of TS declarationsThis PR is a port of #3013 to the
v10
branch.These changes fixes #2997 & drastically simplifies realm/realm-studio#1312
Progress (subject to change)
TS declarations (used in integration-tests)
create<T>(...)
to match a model (using @nirinchev'sExtractPropertyNamesOfType
©) notion of any implications this could introduce, is welcome!.Array<T>
inRealmPartialModel<T>
instead of a definedRealm.Collection<T>
increate<T>(...)
.objects<T>(...)
to accommodate the underlying logic & different responses.Realm.Object
for class models.toJSON
onRealm.Object
&Realm.Collection
(this includesRealm.List
&Realm.Results
)TypeError: Converting circular structure to JSON
is thrown for circular structures, notRangeError: Maximum call stack size exceeded
.* I've included a combined key of the table-type &
_objectId()
as unique$refId
inRealm.JsonSerializationReplacer
, for a (visual) reference in serialized JSON. This is only used in case aprimaryKey
is not defined.Integration Tests
toJSON
implementations for both interface/schema & class model usage.Changelog
CHANGELOG.md