Giter Club home page Giter Club logo

realm / realm-js Goto Github PK

View Code? Open in Web Editor NEW
5.6K 108.0 558.0 99.16 MB

Realm is a mobile database: an alternative to SQLite & key-value stores

Home Page: https://realm.io

License: Apache License 2.0

Objective-C 0.16% JavaScript 2.22% C++ 1.66% Objective-C++ 0.51% Shell 0.31% Java 0.52% PowerShell 0.04% HTML 0.01% Ruby 0.22% Dockerfile 0.12% TypeScript 93.00% CMake 0.60% CSS 0.51% Python 0.01% Kotlin 0.10%
mobile-database nosql-database realm-mobile-database realm mobile-first realtime-database reactive reactnative

realm-js's Introduction

Note

Realm is now Atlas Device SDK - Learn More

realm by MongoDB

The Realm Database

Realm is a mobile database that runs directly inside phones, tablets or wearables. This project hosts the JavaScript & TypeScript implementation of Realm. Currently, we support React Native (JSC & Hermes on iOS & Android), Node.js and Electron (on Windows, MacOS and Linux).

What are the Atlas Device SDKs?

Atlas Device Sync

The Atlas Device SDKs are a collection of language and platform specific SDKs, each with a suite of app development tools optimized for data access and persistence on mobile and edge devices. Use the SDKs to build data-driven mobile, edge, web, desktop, and IoT apps.

It might help to think of the Realm database as the persistance layer of the Atlas Device SDKs.

Features

  • Mobile-first: Realm is the first database built from the ground up to run directly inside phones, tablets and wearables.
  • Simple: Data is directly exposed as objects and queryable by code, removing the need for ORM's riddled with performance & maintenance issues.
  • Modern: The database supports relationships, generics, and vectorization.
  • Fast: It is faster than even raw SQLite on common operations, while maintaining an extremely rich feature set.
  • MongoDB Atlas Device Sync: Makes it simple to keep data in sync across users, devices, and your backend in real time. Get started for free with a template application and create the cloud backend.

Getting Started

Please see the detailed instructions in our docs to use Atlas Device SDK for Node.js and Atlas Device SDK for React Native. Please notice that currently only Node.js version 18 or later is supported. For React Native users, we have a compatibility matrix showing which versions are supported.

Documentation

Atlas Device SDKs for React Native and Node.js

The documentation for the Atlas Device SDK for React Native can be found at mongodb.com/docs/atlas/device-sdks/sdk/react-native/. The documentation for the Atlas Device SDK for Node.js can be found at mongodb.com/docs/atlas/device-sdks/sdk/node/.

The API reference is located at docs.mongodb.com/realm-sdks/js/latest/.

If you are using React Native, please also take a look the README for @realm/react, which provides React hooks to make working with Realm easier.

TypeScript models

TypeScript is a popular alternative to pure JavaScript as it provide static typing. Our TypeScript support consists of two parts

  • Accurate TypeScript definitions @realm/babel-plugin to transform TypeScript classes to Realm schemas. An example of a model class is:
class Task extends Realm.Object<Task, "description"> {
  _id = new Realm.BSON.ObjectId();
  description!: string;
  @index
  isComplete = false;

  static primaryKey = "_id";

  constructor(realm, description: string) {
    super(realm, { description });
  }
}

Integration with React Native

The Atlas Device SDK for React Native provides persistence of objects and advanced queries for persisted objects. You can have easier integration with React Native by using @realm/react.

Template apps

We have TypeScript templates to help you get started using Realm. Follow the links to your desired template and follow the instructions there to get up and running fast.

Getting Help

  • Need help with your code?: Look for previous questions on the #realm tag — or ask a new question. You can also check out our Community Forum where general questions about how to do something can be discussed.
  • Have a bug to report? Open an issue. If possible, include the version of Realm, a full log, the Realm file, and a project that shows the issue.
  • Have a feature request? Open an issue. Tell us what the feature should do, and why you want the feature.

Contributing

See CONTRIBUTING.md for more details!

Known issues

  • Realm is not compatible with the legacy Chrome Debugger. The following debugging methods are supported:
    • Hermes Debugger is the recommended way for debugging modern React Native apps.
    • Safari also has a similar feature set, but requires some setup and only supports debugging in iOS.
    • NOTE: For the above methods, it is not necessary to enable Debug with Chrome in the Debug Menu.

Building the SDK

For instructions on building the SDK from the source, see the building.md file.

Troubleshooting missing binary

It's possible after installing and running Realm that one encounters the error Could not find the Realm binary. Here are are some tips to help with this.

Compatibility

Consult our COMPATIBILITY.md to ensure you are running compatible version of realm with the supported versions of node, react-native or expo.

React Native

iOS

Typically this error occurs when the pod dependencies haven't been updating. Try running the following command

npx pod-install

If that still doesn't help it's possible there are some caching errors with your build or your pod dependencies. The following commands can be used to safely clear these caches:

rm -rf ios/Pods
rm ios/Podfile.lock
rm -rf ~/Library/Developer/Xcode/DerivedData

Afterwards, reinstall pods and try again. If this still doesn't work, ensure that node_modules/realm/react-native/ios/realm-js-ios.xcframework exists and contains a binary for your architecture. If this is missing, try reinstalling the `realm`` npm package.

Android

This can occur when installing realm and not performing a clean build. The following commands can be used to clear your cache:

cd android
./gradlew clean

Afterwards, try and rebuild for Android. If you are still encountering problems, ensure that node_moduels/realm/react-native/android/src/main/jniLibs contains a realm binary for your architecture. If this is missing, try reinstalling the realm npm package.

Expo

If you are using Expo, a common pitfall is not installing the expo-dev-client and using the Development Client specific scripts to build and run your React Native project in Expo. The Development Client allows you to create a local version of Expo Go which includes 3rd party libraries such as Realm. If you would like to use realm in an Expo project, the following steps can help.

  • install the expo-dev-client:
    npm install expo-dev-client
    
  • build the dev client for iOS
    npx expo run:ios
    
  • build the dev client for Android
    npx expo run:android
    
  • start the bundler without building
    npx expo start --dev-client
    

Node/Electron

When running npm install realm the realm binaries for the detected architecture are downloaded into node_modules/realm/prebuilds. If this directory is missing or empty, ensure that there weren't any network issues reported on installation.

Analytics

Asynchronously submits install information to Realm.

Why are we doing this? In short, because it helps us build a better product for you. None of the data personally identifies you, your employer or your app, but it will help us understand what language you use, what Node.js versions you target, etc. Having this info will help prioritizing our time, adding new features and deprecating old features. Collecting an anonymized application path & anonymized machine identifier is the only way for us to count actual usage of the other metrics accurately. If we don’t have a way to deduplicate the info reported, it will be useless, as a single developer npm install-ing the same app 10 times would report 10 times more than another developer that only installs once, making the data all but useless. No one likes sharing data unless it’s necessary, we get it, and we’ve debated adding this for a long long time. If you truly, absolutely feel compelled to not send this data back to Realm, then you can set an env variable named REALM_DISABLE_ANALYTICS.

Currently the following information is reported:

  • What version of Realm is being installed.
  • The OS platform and version which is being used.
  • If a JavaScript framework (currently React Native and Electron) is used and its version.
  • Which JavaScript engine is being used.
  • Node.js version number.
  • TypeScript version if used.
  • An anonymous machine identifier and hashed application name to aggregate the other information on.

Moreover, we unconditionally write various constants to a file which we might use at runtime.

Code of Conduct

This project adheres to the MongoDB Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

License

Realm JS and Realm Core are published under the Apache License 2.0.

Feedback

If you use Realm and are happy with it, all we ask is that you please consider sending out a tweet mentioning @realm to share your thoughts

And if you don't like it, please let us know what you would like improved, so we can fix it!

Contributors

Made with contrib.rocks.

realm-js's People

Contributors

alazier avatar alebsack avatar appden avatar ashwinphatak avatar bdash avatar blagoev avatar bmunkholm avatar cesarvr avatar cmelchior avatar dependabot[bot] avatar depfu[bot] avatar elle-j avatar emanuelez avatar fealebenpae avatar fronck avatar github-actions[bot] avatar iamer avatar kneth avatar kraenhansen avatar kristiandupont avatar nhachicha avatar nirinchev avatar papafe avatar radu-tutueanu avatar realm-ci avatar redbeard0531 avatar steffenagger avatar takameyer avatar tgoyne avatar tomduncalf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

realm-js's Issues

Query Syntax

I might be a good idea to take a in an object (key value pairs) for querying instead of having people put together a string.

It would work for single parameter queries. If there are multiple it would assume AND -- these seems to be the most common case.

Notes;

  • allow empty query or null to be no filters
  • auto escape strings and such
  • ideally on a string or int column, i should be able to give an array - this would translate to an IN query if it was MySQL. ActiveRecord does this and I think it's super useful.

React Example Loading

the first complaint was that i couldn't find node
I am using nvm so added source ~/.nvm/nvm.sh in the sample Run Script.
That seemed to get past it

Support optional properties

some of the issues that I'm seeing could be attributed to crashing if the value is undefined.

I'm calling realm.create(data)
let's say the table has a column named title but I leave it off the data object.

I think it's crashing with "should be a string"
I was expecting it to set the value to NULL if left off.

Does Not build in react-native 0.11.0

ld: warning: embedded dylibs/frameworks are only supported on iOS 8.0 and later (@rpath/RealmJS.framework/RealmJS)
Undefined symbols for architecture x86_64:
  "_RCTGetLatestExecutor", referenced from:
      -[Realm setBridge:] in libRealmReact.a(RealmReactModule.o)

reset db

For tests, we need to clear/truncate all the tables.
What's the best what to do that?
I'm currently iterating through each and realm.objects(name).delete(results);

Is there one method to start over the whole db?

Support all applicable JS Array methods on List and Results

From @appden :

I'd like to modify the array and results implementations to properly inherit from the native JS Array so we can leverage all of its methods. To do this, we just need to implement getters (and setters in the case of Array) for indices and the "length" property. JavaScriptCore will handle everything if we just do that (I believe the spec enforces this behavior, but I'm not quite sure of the details). Its native class name should be "Array" as well since many libraries expect this to check if an object is an array.

Can't find variable: RealmType

Something is happening that prevents the injection of the Realm and RealmType globals in to the JS framework when you upgrade react to the current version.

You can see the issue in the example app if you change the package.json to:

  "dependencies": {
    "react-native": "0.10.0"
  }

Actually test that the ReactExample loads propertly

Our single test currently waits for a few seconds to make sure no exceptions are thrown. We should change the test to make sure the UI actually loads property. I was unable to get the current check to work in the few minutes I spent on it so commented out the relevant check.

mass updates

is there a way to UPDATE table_name SET prop1=14 WHERE prop2='key' ?

Better handle object property comparison/equality/identity

If you get a non primitive property it will not be the same object that was set. From @appden :

it would be ideal for objects (i.e. non-primitive values) to survive a roundtrip. Right now the getters look like they always return a new JS object, which will inevitably cause unexpected weirdness in JS code, especially now that we have native Map and Set collections. As long as each object in Realm has a unique identifier, I think this will be relatively easy to achieve

Test suite should run in all supported environments

I wanted to be sure this was tracked. I really like that the current tests run inside Xcode and now will report the exact failure location in JS (see #29). However, we also will need to run these tests inside all of our supported platforms: iOS/Android devices, inside Chrome (once we get that working), Node, etc.

I propose that we migrate our existing test suite to use Mocha. Since Mocha is very modular with swappable assertion libraries and reporters, we'll be able to easily support all environments including Xcode. We can even write a custom reporter that shows test progress with React Native views. It'll be trivial to write a reporter to leverage our existing test suite code to report failure info in Xcode. The existing Terminal and DOM reporters will work well with our respective Node and Chrome environments as well. 😄

Run tests from ReactNative

We need to be able to do this both with and without chrome debugging.

For ci, we need to be able to run the tests from the commandline either through XCode or another test harness.

Partial updates

say i know the primary key - is there a way to update just a few of the properties?
right now it all goes through create (with the true flag) and it crashes if all the properties are not set.

Storing JSON

React uses AsyncStorage and we can just write an object (json) to disk.

I'm thinking I want to do that in Realm. That is, any given table would have a "document" column and I'd put a bunch of JSON in there. The other columns would only be things I wanted to filter or sort by.

Is that crazy? Here are some of the benefits

  • I can actually have a null value :-)
  • I can do simple nesting - which is a easier and more reliable than making object graphs in the db
  • less migrations
  • more or less can cache what comes from the server

The downsides are probably something like the downsides to NoSQL in general

  • there are still "migrations" - it's just internal versioning stuff

If it is a not-crazy idea, would I just store a String of the json or is there some more native way to do it?
Is there a string size limit? I see something about 16 MB in the docs for a property.

Change schema definition format

@appden :

I think JS devs would generally prefer to write out regular objects in similar way as the React.PropTypes API, and I think it would make it easier to read code wherever those objects are created. It also would allow devs to reorder the property definitions for cleanliness without worrying about breaking lots of code. We can discuss this more next week – perhaps there are benefits I'm not realizing.

Sample Project

Maybe some documentation on the sample react project?

I did an npm install then launched the xcode proj
It's still giving me a build error

screen shot 2015-08-25 at 5 25 45 pm

Thoughts on that?

assert on mass delete.

I have a table with about 30 rows or so. I was trying to simulate the "delete with a query" method I'd like.

RealmStore.prototype.deleteAll = function(query) {
  realm.write(function() {
    this._deleteAll(query);
  }.bind(this));
};

RealmStore.prototype._deleteAll = function(query) {
  // TODO: optimize to one call
  var results = realm.objects(this.name, query);
  var toDelete = [];
  for (var i=0; i < results.length; i++) {
    toDelete.push(results[i]);
  }

  if (toDelete.length > 0) {
    realm.delete(toDelete);
  }
};

This causes the crash below.
Another note: At one point I was deleting them one at a time in the loop. This did not crash but also did not actually delete them all.

table.cpp:1983: [realm-core-0.92.0] Assertion failed: row_ndx < m_size [19, 18]
0   RealmJS                             0x00000001101f5261 _ZN5realm4util18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 40
1   RealmJS                             0x0000000110147ae0 _ZN5realm4util9terminateImmEEvPKcS3_lT_T0_ + 1600
2   RealmJS                             0x000000011022edb4 _ZN5realm5Table9erase_rowEmb + 436
3   RealmJS                             0x00000001101b2949 _ZN5realm5Table6removeEm + 41
4   RealmJS                             0x00000001101ec69b _Z11RealmDeletePK15OpaqueJSContextP13OpaqueJSValueS3_mPKPKS2_PS5_ + 1067
5   RealmJS                             0x00000001101ec394 _Z11RealmDeletePK15OpaqueJSContextP13OpaqueJSValueS3_mPKPKS2_PS5_ + 292
6   JavaScriptCore                      0x000000010e0c6825 _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 517
7   JavaScriptCore                      0x000000010e18d326 _ZN3JSC5LLInt9setUpCallEPNS_9ExecStateEPNS_11InstructionENS_22CodeSpecializationKindENS_7JSValueEPNS_17LLIntCallLinkInfoE + 454
8   JavaScriptCore                      0x000000010e194387 llint_entry + 22753
9   JavaScriptCore                      0x000000010e194327 llint_entry + 22657
10  JavaScriptCore                      0x000000010e18e881 callToJavaScript + 311
11  JavaScriptCore                      0x000000010e072ea3 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 35
12  JavaScriptCore                      0x000000010e0558a0 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 480
13  JavaScriptCore                      0x000000010de91fde _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62
14  JavaScriptCore                      0x000000010e0c59fd _ZN3JSC17boundFunctionCallEPNS_9ExecStateE + 605
15  JavaScriptCore                      0x000000010e18ea1f callToNativeFunction + 317
16  JavaScriptCore                      0x000000010e0558ef _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 559
17  JavaScriptCore                      0x000000010de91fde _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62
18  JavaScriptCore                      0x000000010e116190 JSObjectCallAsFunction + 688
19  RealmJS                             0x00000001101ec996 _Z10RealmWritePK15OpaqueJSContextP13OpaqueJSValueS3_mPKPKS2_PS5_ + 294
20  JavaScriptCore                      0x000000010e0c6825 _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 517
21  JavaScriptCore                      0x000000010e18d326 _ZN3JSC5LLInt9setUpCallEPNS_9ExecStateEPNS_11InstructionENS_22CodeSpecializationKindENS_7JSValueEPNS_17LLIntCallLinkInfoE + 454
22  JavaScriptCore                      0x000000010e194387 llint_entry + 22753
23  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
24  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
25  ???                                 0x0000013fd92ece4d 0x0 + 1373738290765
26  ???                                 0x0000013fd9393407 0x0 + 1373738972167
27  JavaScriptCore                      0x000000010e194392 llint_entry + 22764
28  JavaScriptCore                      0x000000010e194392 llint_entry + 22764
29  JavaScriptCore                      0x000000010e194392 llint_entry + 22764
30  JavaScriptCore                      0x000000010e194392 llint_entry + 22764
31  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
32  JavaScriptCore                      0x000000010e19455c llint_entry + 23222
33  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
34  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
35  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
36  JavaScriptCore                      0x000000010e194327 llint_entry + 22657
37  ???                                 0x0000013fd93ace08 0x0 + 1373739077128
38  ???                                 0x0000013fd9349775 0x0 + 1373738669941
39  ???                                 0x0000013fd928ca6f 0x0 + 1373737896559
40  ???                                 0x0000013fd927439d 0x0 + 1373737796509
41  ???                                 0x0000013fd9297cbe 0x0 + 1373737942206
42  ???                                 0x0000013fd93311da 0x0 + 1373738570202
43  ???                                 0x0000013fd921a44a 0x0 + 1373737428042
44  ???                                 0x0000013fd92974ee 0x0 + 1373737940206
45  ???                                 0x0000013fd926f318 0x0 + 1373737775896
46  ???                                 0x0000013fd91f59fa 0x0 + 1373737277946
47  ???                                 0x0000013fd9293813 0x0 + 1373737924627
48  ???                                 0x0000013fd91f5a3a 0x0 + 1373737278010
49  ???                                 0x0000013fd9259a59 0x0 + 1373737687641
50  ???                                 0x0000013fd9296a67 0x0 + 1373737937511
51  JavaScriptCore                      0x000000010e18e881 callToJavaScript + 311
52  JavaScriptCore                      0x000000010e072ea3 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 35
53  JavaScriptCore                      0x000000010e0558a0 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 480
54  JavaScriptCore                      0x000000010de91fde _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62
55  JavaScriptCore                      0x000000010e0c59fd _ZN3JSC17boundFunctionCallEPNS_9ExecStateE + 605
56  JavaScriptCore                      0x000000010e18ea1f callToNativeFunction + 317
57  JavaScriptCore                      0x000000010e0558ef _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 559
58  JavaScriptCore                      0x000000010de91fde _ZN3JSC4callEPNS_9ExecStateENS_7JSValueENS_8CallTypeERKNS_8CallDataES2_RKNS_7ArgListE + 62
59  JavaScriptCore                      0x000000010e116190 JSObjectCallAsFunction + 688
60  Tasker                              0x000000010c18a00d __62-[RCTContextExecutor executeJSCall:method:arguments:callback:]_block_invoke_2 + 1389
61  Tasker                              0x000000010c1897e0 __62-[RCTContextExecutor executeJSCall:method:arguments:callback:]_block_invoke + 368
62  Tasker                              0x000000010c18b798 -[RCTContextExecutor executeBlockOnJavaScriptQueue:] + 248
63  Tasker                              0x000000010c189565 -[RCTContextExecutor executeJSCall:method:arguments:callback:] + 821
64  Tasker                              0x000000010c193dcb -[RCTBatchedBridge _actuallyInvokeAndProcessModule:method:arguments:] + 1051
65  Tasker                              0x000000010c196bd9 -[RCTBatchedBridge _jsThreadUpdate:] + 2857
66  QuartzCore                          0x000000010ebcc10f _ZN2CA7Display15DisplayLinkItem8dispatchEv + 37
67  QuartzCore                          0x000000010ebcbfd7 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 315
68  CoreFoundation                      0x000000010d36f174 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
69  CoreFoundation                      0x000000010d36ed35 __CFRunLoopDoTimer + 1045
70  CoreFoundation                      0x000000010d330d3d __CFRunLoopRun + 1901
71  CoreFoundation                      0x000000010d330366 CFRunLoopRunSpecific + 470
72  Tasker                              0x000000010c18778b +[RCTContextExecutor runRunLoopThread] + 363
73  Foundation                          0x000000010c64c09d __NSThread__main__ + 1194
74  libsystem_pthread.dylib             0x00000001109ef05a _pthread_body + 131
75  libsystem_pthread.dylib             0x00000001109eefd7 _pthread_body + 0
76  libsystem_pthread.dylib             0x00000001109ec3ed thread_start + 13
IMPORTANT: if you see this error, please send this log to [email protected].

Can not run React example on phone

Selecting plugged in iPhone as target (after compiling jS and changing app delegate.

dyld`dyld_fatal_error:
->  0x1200a1088 <+0>: brk    #0x3
dyld: Library not loaded: @rpath/RealmJS.framework/RealmJS
  Referenced from: /private/var/mobile/Containers/Bundle/Application/F34937D1-35DE-489C-87A7-0A2666B63130/ReactExample.app/ReactExample
  Reason: image not found

sort order

i don't see an api for sorting. current use cases involve int columns.

Support nested transactions

This is a common pattern with most databases. Right now, methods that do mutations generally shouldn't call realm.write() because you may which to call multiple mutating methods all inside a single transaction. When the codebases get larger, this maybe be difficult to manage without nested transaction support.

Support migrations / reloading during developement

One really great thing about React Native is the ability to reload (cmd + R).
I've just noticed that (understandably) this causes some problems when fiddling around with the schema.

The first thing I noticed is that it doesn't take effect until a hard relaunch of the app from XCode.
The second is that it then requires a migration (maybe because I changed a column type - not sure about adding a column yet).

I'm not sure the right solve for these, but thought I'd note things as I encounter them.

Support react-native android

Steps needed to make this happen:

  • Build a native module which includes all the cpp files here https://github.com/realm/realm-js/tree/al-android/src - If the JSCore apis are really the same then everything here should pretty much just work
  • Implement the platform specific methods for java/android - empty implementations are in this file https://github.com/realm/realm-js/blob/al-android/src/android/platform.cpp
  • Get a hold of the JSContextRef created here and call RJSInitializeInContext with this context to initialize our apis. On iOS we do this in our native module whenever the Bridge gets set. All of the contexts seem to be available in this global variable static std::unordered_map<JSContextRef, JSCExecutor*> s_globalContextRefToJSCExecutor;. If we can find a way to access this from our module initializing the context should be straightforward. Alternatively we can change the react-native implementation in a cleaner way in order to expose the JSContext in a cleaner way. Ideally this would be exposed through a jni method on one of the Java objects passed into our native module during initialization. This will require building our own custom version of react-native until we can make a pr against their repo, but this may be the route that we need to follow.
  • Get chrome debugging working. This involves added an http server which hooks into the existing rpc code, and hooking into react native to initialize this webserver whenever chrome debugging mode is used.

New query engine

We need a query engine that works cross platform and does not rely on objc.

Here are the notes on the subject from Realmstravaganza:

  • What do we do for javascript?
    • NSPredicate?
    • Builder pattern like java?
    • LINQ like system?
  • Java - builder pattern - can fail at runtime with type mismatches
    • people asking for limit/distinct
    • location of sort method this confusing - strict ordering could address this
  • JS - consider apis similiar to underscore/lowdash
    • explore lambda functions in js - if we can extract an expression tree from lamda expressions we could have a linq like interface
    • if we can make linq like system work we should.
  • Single query language to rule them all doesn't seem practical.

Realm apis should follow JS Conventions

@appden :

I think it's best to follow JS conventions and use the Realm constructor as a namespace for the other ones (i.e. Realm.Type, Realm.Object, and a future Realm.Array). JavaScript devs will appreciate this and it'll make it easier to modularize with ES6 modules as well.

@appden feel free to suggest alternatives here.

Reloading in chrome is broken

If you reload the app while in chrome debugging, you can end up in a situation where you have an old js context sending requests to a server associated with the reloaded context.

The solution for this issue is to have a sessionID associated with each rpcServer, and to support simultaneous requests to multiple rpcServers both for the current and old remote jscontexts. We can support these on a single port so we only need one webserver instance.

REPL for development/api experiementation

From @appden :

I think it would be pretty easy to setup a REPL build target using some private JSC APIs. They have a pretty robust REPL implementation that I think we could hook into. This would helpful as a playground for testing things out during development, but more importantly, for users of the JS APIs to learn and try new things quickly.

Consolidate/Cleanup object_store code

Right now we check for realm->is_in_transaction() inside object_accessor code for settings properties and creating new objects, but in the JSC layer for deleting objects and mutating arrays. All of this checks should be inside the object_store layer, which may mean adding new C++ methods for deletion and mutations. This will be good anyways in order to have less code duplication inside the Node API.

Also, from @alazier:

We will want to define a new exception type for mutations outside of write transactions, as other platforms will need to catch this and possibly handle this specific cases anywhere we throw from the shared object store code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.