Expose List Type Field in realmObject
See original GitHub issueGoals
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
- Create an Object with list type fields in your object.
- Store some instances of this object in realm.
- Query at least on of them after you store them.
- 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:
- Created 6 years ago
- Reactions:2
- Comments:6 (3 by maintainers)
Top GitHub Comments
@fealebenpae I know that, and the performance I measured without Chrome Debugger is not good neither.
Please note that if you’re running inside the Chrome DevTools debugger Realm is going to perform more poorly than without a debugger.