question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expose List Type Field in realmObject

See original GitHub issue

Goals

If I have a field defined for a realm object Business as number_of_inventory_of_stores: 'int[]', I want to copy this list to another javascript list out of the realm object Business after querying it from realm in a fast fashion.

For ex, this will be one of the expected way of achieving my goal var js_number_of_inventory_of_stores = Business.number_of_inventory_of_stores.targetList

Expected Results

The expected results will be the array number_of_inventory_of_stores is copied to js_number_of_inventory_of_stores that takes no more than a few ms with a relatively small length like 1000.

Actual Results

Currently I think I don’t have access to internal [[Handler]] and [[Target]] slots of the list Proxy, so I tried

var js_number_of_inventory_of_stores = Array.prototype.slice.call(number_of_inventory_of_stores)

and

var js_number_of_inventory_of_stores = _.values(number_of_inventory_of_stores)

and

var js_number_of_inventory_of_stores = Array.from(number_of_inventory_of_stores)

that had been discussed in #280. All of the methods copied the data, but the performance is unexpectedly slow. For a 2500-length array, the copying process took roughly 10 seconds.

Steps to Reproduce

  1. Create an Object with list type fields in your object.
  2. Store some instances of this object in realm.
  3. Query at least on of them after you store them.
  4. Try to copy the fields to a plain javascript array.

Version of Realm and Tooling

  • Realm JS SDK Version: realm@2.2.15
  • Node or React Native: node v6.9.5 & react-native@0.51.0
  • Client OS & Version: macOS High Sierra 10.13.1
  • Which debugger for React Native: Chrome Debugger

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
LingboTangcommented, Apr 16, 2018

@fealebenpae I know that, and the performance I measured without Chrome Debugger is not good neither.

0reactions
fealebenpaecommented, Apr 14, 2018

Please note that if you’re running inside the Chrome DevTools debugger Realm is going to perform more poorly than without a debugger.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Type 'int[]' of field is not supported | how to add integer list ...
What to do with this? I tried with List but no luck. Then i realized that Integer object doesn't extends RealmObject so I...
Read more >
Integrating Realm Database in an Android Application
In the above, we create a Realm model classe by extending the RealmObject base class. Realm supports the following field types: boolean ...
Read more >
Filter Data - Java SDK — Realm
Queries return a list of references to the matching Realm objects using the RealmResults type. Tip. See also: Fundamentals: Query Engine.
Read more >
Realm Object Server Documentation
The Realm Object Server must have read/write access to the directory pointed to ... or expose the backend services on the network for...
Read more >
Why Realm is a great persistence solution for beginners in ...
You can only store the field types that are allowed (…, boolean, String, Date, Long, Double, ByteArray, specific RealmObject types, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found