realm / realm-dart

Realm is a mobile database: a replacement for SQLite & ORMs.
Apache License 2.0
772 stars 86 forks source link

Add JSON encoding support for ObjectId #1791

Closed ganwumeng closed 2 months ago

ganwumeng commented 2 months ago

Problem

While trying to use

List<ObjectId> objectIdList = [...];
jsonEncode(objectIdList);

, throw an exception:

Converting object to an encodable object failed: Instance of 'ObjectId'

Solution

Add tojson and fromjson function

Alternatives

No response

How important is this improvement for you?

Fairly niche but nice to have anyway

Feature would mainly be used with

Local Database only

sync-by-unito[bot] commented 2 months ago

➤ PM Bot commented:

Jira ticket: RDART-1097

nirinchev commented 2 months ago

ObjectId comes from https://pub.dev/packages/objectid and is not a type we maintain ourselves. Might be worth asking in https://github.com/gonuit/dart_objectid or submitting a PR to the library.