Skip to content

Releases: realm/realm-js

Realm JavaScript v12.0.0-rc.0

29 Jun 07:37
d038e44
Compare
Choose a tag to compare
Pre-release

Breaking changes

  • Now exporting only as CommonJS, to align with the way we exported from v11 in an attempt to keep breakage across the major version to an absolute minimum. This is a breaking change compared to the previous pre-releases of v12, since users have to update code which is doing named import of Realm to use default or * as Realm imports of the Realm constructor. (#5882)
  • SyncSession JS objects no longer keep their associated C++ objects, and therefore the sync network connection, alive. This was causing issues because JS garbage collection is lazy so the SyncSession may survive much longer than the last reference held to it. We now use the same technique as v11 to avoid keeping the C++ object alive (std::weak_ptr). (#5815, since v12.0.0-alpha.0)
    • Breaking change: On v11, if the C++ object had been destroyed already, we would often return undefined or some other default value when calling methods or accessing properties on the JS SyncSession object, even if that would violate our declared TS types. Now, in v12, we will throw from all methods and property accessors in this case.

Deprecations

  • Deprecated the SubscriptionsState enum (will be removed in v13) in favor of the now-named SubscriptionSetState. (#5773)
  • Removed deprecation of the Realm namespace, to align with v11 and ease the adoption of this major version. (#5883)

Enhancements

  • Opening a Realm with invalid schemas will throw a SchemaParseError (or one of its subtypes ObjectSchemaParseError and PropertySchemaParseError) rather than an AssertionError or Error. (#5198)

  • Enable multiple processes to operate on an encrypted Realm simultaneously. (realm/realm-core#1845)

  • Added Realm.setLogger, that allows to setup a single static logger for the duration of the app lifetime. Differently from the now deprecated sync logger (that was setup with Sync.setLogger), this new one will emit messages coming also from the local database, and not only from sync. It is also possible to change the log level during the whole duration of the app lifetime with Realm.setLogLevel. (#2546)

  • Added support for a sync configuration option to provide an SSLConfiguration with a custom function for validating the server's SSL certificate. (#5485)

  • Improve performance of equality queries on a non-indexed mixed property by about 30%. (realm/realm-core#6506)

  • Improve performance of rolling back write transactions after making changes. (realm/realm-core#6513)

  • Extended PropertySchema.indexed with the full-text option, that allows to create an index for full-text search queries. (#5755)

  • Access token refresh for websockets was not updating the location metadata (realm/realm-core#6630, since v11.9.0)

  • Fix several UBSan failures which did not appear to result in functional bugs (realm/realm-core#6649).

  • Using both synchronous and asynchronous transactions on the same thread or scheduler could hit an assertion failure if one of the callbacks for an asynchronous transaction happened to be scheduled during a synchronous transaction (realm/realm-core#6659, since v10.12.0)

  • Added APIs to facilitate adding and removing subscriptions. (#5772)

    • Experimental APIs: Enabled subscribing and unsubscribing directly to and from a Results instance via Results.subscribe() (asynchronous) and Results.unsubscribe() (synchronous).
      • Added a WaitForSync enum specifying whether to wait or not wait for subscribed objects to be downloaded before resolving the promise returned from Results.subscribe().
      • Extended SubscriptionOptions to take a WaitForSync behavior and a maximum waiting timeout before returning from Results.subscribe().
    • Added the instance method MutableSubscriptionSet.removeUnnamed() for removing only unnamed subscriptions.
    const peopleOver20 = await realm
      .objects("Person")
      .filtered("age > 20")
      .subscribe({
        name: "peopleOver20",
        behavior: WaitForSync.FirstTime, // Default
        timeout: 2000,
      });
    // ...
    peopleOver20.unsubscribe();
  • Added initial support for geospatial queries, with the possibility of querying points. No new data type has been added in this phase, but every embedded object property that conforms to CanonicalGeoPoint can be queried. (#5850)

    • The queries can be used to filter objects whose points lie within a certain area following spherical geometry, using the geoWithin operator in the query string to Results.filtered().
    • The following shapes are supported in geospatial queries: circle (GeoCircle type, defined by its center and radius in radians), box (GeoBox type, defined by its bottom left and upper right corners) and polygon (GeoPolygon type, defined by its vertices).
    • Additionally, two new functions have been added, kmToRadians() and miToRadians(), that can be used to convert kilometers and miles to radians respectively, simplifying conversion of a circle's radius.
    import Realm, {
      ObjectSchema,
      GeoCircle,
      CanonicalGeoPoint,
      GeoPosition,
      kmToRadians,
    } from "realm";
    
    // Example of a user-defined point class that can be queried using geospatial queries
    class MyGeoPoint extends Realm.Object implements CanonicalGeoPoint {
      coordinates!: GeoPosition;
      type = "Point" as const;
    
      static schema: ObjectSchema = {
        name: "MyGeoPoint",
        embedded: true,
        properties: {
          type: "string",
          coordinates: "double[]",
        },
      };
    }
    
    class PointOfInterest extends Realm.Object {
      name!: string;
      location!: MyGeoPoint;
    
      static schema: ObjectSchema = {
        name: "PointOfInterest",
        properties: {
          name: "string",
          location: "MyGeoPoint",
        },
      };
    }
    
    realm.write(() => {
      realm.create(PointOfInterest, {
        name: "Copenhagen",
        location: {
          coordinates: [12.558892784045568, 55.66717839648401],
          type: "Point",
        } as MyGeoPoint
      });
      realm.create(PointOfInterest, {
        name: "New York",
        location: {
          coordinates: [-73.92474936213434, 40.700090994927415],
          type: "Point",
        } as MyGeoPoint
      });
    });
    
    const pois = realm.objects(PointOfInterest);
    
    const berlinCoordinates: GeoPoint = [13.397255909303222, 52.51174463251085];
    const radius = kmToRadians(500); //500 km = 0.0783932519 rad
    
    // Circle with a radius of 500kms centered in Berlin
    const circleShape: GeoCircle = {
      center: berlinCoordinates,
      distance: radius,
    };
    
    // All points of interest in a 500kms radius from Berlin
    let result = pois.filtered("location geoWithin $0", circleShape);
    
    // Equivalent string query without arguments
    result = pois.filtered("location geoWithin geoCircle([13.397255909303222, 52.51174463251085], 0.0783932519)");
  • Support sort/distinct based on values from a dictionary e.g. TRUEPREDICATE SORT(meta['age']). (realm/realm-core#5311)

  • Support for HTTP proxy settings in the Realm configuration by adding proxyConfig to the sync configuration. You can continue to use environment variable HTTPS_PROXY. HTTP proxies are only supported for node.js and Electron. (#5816)

proxyConfig: {
  address: "127.0.0.1",
  port: 9876,
  type: ProxyType.HTTP,
}

Fixed

  • Fix a stack overflow crash when using the query parser with long chains of AND/OR conditions. (realm/realm-core#6428, since v10.11.0)
  • Fixed an issue that could have resulted in a client reset action being reported as successful when it actually failed on windows if the Realm was still open (realm/realm-core#6050).
  • Fix a data race that could cause a reading thread to read from a no-longer-valid memory mapping (realm/realm-core#6411, since v11.3.0-rc.0).
  • Fixed an issue that could cause a crash when performing count() on an undefined query. (realm/realm-core#6443, since v12.0.0-alpha.2)
  • Added missing implementation of User.state and changed the UserState enum values to use pascal case to conform to the v11 implementation (except for UserState.Active that we now deprecate in favor of UserState.LoggedIn). (#5686)
  • Getting the indexOf a missing value will no longer return 4294967295 instead of -1 and the Set#has will no longer return true when missing. Caused by an incorrect conversion of size_t to Number on x86 (32bit) architectures. (#5746, since 12.0.0-alpha.0)
  • Fixed App.currentUser() when being called on a new instance of App (#5790)
  • Fixed an error where performing a query like "{1, 2, 3, ...} IN list" where the array is longer than 8 and all elements are smaller than some values in list, the program would crash. (realm/realm-core#6545, since v10.20.0...
Read more

Realm React v0.5.1

21 Jun 08:31
d91cc64
Compare
Choose a tag to compare

Fixed

  • Include the src in the distributed package. This fixes a warning about source maps being not included.
  • Get the useAuth and useEmailPasswordAuth tsdoc to appear on hover over for LSP enabled IDEs.
  • useEmailPasswordAuth was crashing on v11 since there are no named exports on Realm.

Internal

  • Refactor useAuthOperation to use the reject callback rather than catch.
  • Refactor useAuthOperation to not return a result. All methods are void.

Realm React v0.5.0

19 Jun 14:46
32d2e47
Compare
Choose a tag to compare

Enhancements

  • Add authentication hooks, useAuth and useEmailPasswordAuth
    Usage example

  • Allow useQuery to be passed a query function where sorted and filtered methods can be called (#5471) Thanks for the contribution @levipro!

    Example:

     const SomeComponent = () => {
         const user = useUser();
         const items = useQuery(Item,
             (res) => res.filtered(`owner_id == "${user?.id}"`).sorted('createdAt'),
             [user]
         );
     };
  • Create a default context so the RealmProvider, useQuery, useRealm, and useObject can be directly imported from @realm/react (#5292)

    Example:

     // These imports are now available without calling `createRealmContext`
     import {RealmProvider, useQuery} from '@realm/react'
     //...
     // Provider your schema models directly to the realm provider
     <RealmProvider schema={[Item]}>
     	<SomeComponent/>
     </RealmProvider>
    
     const SomeComponent = () => {
     	const items = useQuery(Item)
    
     	//...
     }

    NOTE: If your app is using multiple Realms, then you should continue using createRealmContext

Fixed

  • useUser is now typed to never returned null #4973
    Example:
     const user = useUser();
     // before
     console.log(user?.id); // Optional chaining required
     // now
     console.log(user.id); // No typing error
    

Compatibility

  • React Native >= v0.70.0
  • Atlas App Services.
  • Realm Studio v13.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Realm JavaScript v11.10.1

16 Jun 21:00
Compare
Choose a tag to compare

Fixed

  • Fixed incorrect Linux build (x86_64) for older Linux distributions, and loading the binary will fail with Error: /lib64/libc.so.6: version 'GLIBC_2.34' not found.

Compatibility

  • React Native >= v0.71.3
  • Realm Studio v14.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

Realm JavaScript v11.10.0

15 Jun 16:03
Compare
Choose a tag to compare

Enhancements

  • Support sort/distinct based on values from a dictionary e.g. TRUEPREDICATE SORT(meta['age']). (realm/realm-core#5311)

Fixed

  • Partition-Based to Flexible Sync Migration for migrating a client app that uses partition based sync to use flexible sync under the hood if the server has been migrated to flexible sync is officially supported with this release. Any clients using an older version of Realm will receive a "switch to flexible sync" error message when trying to sync with the app. (realm/realm-core#6554, since v11.9.0)
  • Calling snapshot() on a Realm list of primitive types is not supported and now throws.
  • Fixed a potential crash when opening the realm after failing to download a fresh FLX realm during an automatic client reset. (realm/realm-core#6494, since v10.19.5)
  • Changing parameters for a query after initialization could lead to a crash. (realm/realm-core#6674, since v10.20.0)

Compatibility

  • React Native >= v0.71.3
  • Realm Studio v14.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

  • Upgraded Realm Core from v13.10.1 to v13.14.0. (#5811, #5833, and #5868)
  • Bump sync protocol to v9 to indicate client has fix for client reset error during async open. (realm/realm-core#6609)
  • The sync client's user agent has been changed and has now the form RealmJS/<sdk version> (<osname> <sysname> <release> <version> <machine>) where
    • sdk version is the version of Realm JavaScript
    • osname equivalent to uname -o
    • sysname equivalent to uname -s
    • release equivalent to uname -r
    • version equivalent to uname -v
    • machine equivalent to uname -m
  • Aligning analytics with other Realm SDKs. You can still disable the submission by setting environment variable REALM_DISABLE_ANALYTICS, and you can print out what is submitted by setting the environment variable REALM_PRINT_ANALYTICS.

Realm JavaScript v11.9.0

11 May 09:41
Compare
Choose a tag to compare

Enhancements

  • Improve performance of equality queries on a non-indexed mixed property by about 30%. (realm/realm-core#6506)
  • PBS to FLX Migration for migrating a client app that uses partition based sync to use flexible sync under the hood if the server has been migrated to flexible sync. (realm/realm-core#6554)
  • New notifiers can now be registered in write transactions until changes have actually been made in the write transaction. This makes it so that new notifications can be registered inside change notifications triggered by beginning a write transaction (unless a previous callback performed writes). (realm/realm-core#6560)

Fixed

  • If session multiplexing was enabled in the sync client and multiple realms for multiple users were being synchronized, a connection authenticated for the wrong user could have been used, resulting in a UserMismatch error from the server. (realm/realm-core#6320, since v10.0.0).
  • If session multiplexing was enabled and an automatic client reset failed, it could cause all sessions to fail with a fatal ProtocolError rather than just the session that failed to client reset. This would mean that no other sync session would be able to be opened for up to an hour without restarting the app. (realm/realm-core#6320, since v10.10.0)
  • Performing a query like {1, 2, 3, ...} IN list where the array is longer than 8 and all elements are smaller than some values in list, the app would crash. (realm/realm-core#1183, since v10.20.0)
  • Performing a large number of queries without ever performing a write resulted in steadily increasing memory usage, some of which was never fully freed due to an unbounded cache. (realm/realm-swift#7978, since v10.19.0)

Compatibility

  • React Native >= v0.71.0
  • Realm Studio v14.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

Realm JavaScript v11.8.0

12 Apr 19:01
e157bcc
Compare
Choose a tag to compare

NOTE: Since the file format of the Realm auxiliary files have been changed, it is required to use Realm Studio v14.0.0 to open Realm files produced by this release.

Enhancements

Fixed

  • Fix a stack overflow crash when using the query parser with long chains of AND/OR conditions. (realm/realm-core#6428, since v10.11.0)

Compatibility

  • React Native >= v0.71.0
  • Realm Studio v14.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

  • Upgraded Realm Core from v13.8.0 to v13.9.0. (#5720)
  • Turning off the new Realm Core logger. A better solution will be provided in version 12.
  • Tagging on the release branch early to ensure the tag ends on the correct branch. (#5674)

Realm JavaScript v12.0.0-alpha.2

05 Apr 20:21
640280a
Compare
Choose a tag to compare
Pre-release

This is a pre-release of the next major version of our SDK.
Please read more and discuss in the dedicated discussion: https://github.com/realm/realm-js/discussions/5416
See the release notes of previous pre-releases below for a complete picture of the changes introduced since v11.

Enhancements

  • Added support for building with the new React Native architecture enabled on Android. Thanks to
    Nikolai Samorodov / @zabutok for contributing the fix. (#5032)
  • Exposed SyncError.logUrl which contains the URL to the server log related to the sync error. (#5609)
  • Added a new error class CompensatingWriteError which indicates that one or more object changes have been reverted by the server.
    This can happen when the client creates/updates objects that do not match any subscription, or performs writes on an object it didn't have permission to access. (#5599)
  • Performance improvement for the following queries (realm/realm-core#6376):
    • Significant (~75%) improvement when counting (Realm.Results#length) the number of exact matches (with no other query conditions) on a string/int/uuid/objectId property that has an index. This improvement will be especially noticiable if there are a large number of results returned (duplicate values).
    • Significant (~99%) improvement when querying for an exact match on a date property that has an index.
    • Significant (~99%) improvement when querying for a case insensitive match on a mixed property that has an index.
    • Moderate (~25%) improvement when querying for an exact match on a bool property that has an index.
    • Small (~5%) improvement when querying for a case insensitive match on a mixed property that does not have an index.
  • Added a THROW_ON_GLOBAL_REALM which will enable throwing when the app is accessing the Realm without first importing it from the Realm package.

Fixed

  • Fixed bootstrapping the native module on Android. Seen as Exception in HostObject::get for prop 'Realm': java.lang.NoClassDefFoundError: io.realm.react.RealmReactModule. (#5666, since v12.0.0-alpha.0)
  • Fixed passing RealmObject instances between shared Realms. (#5634, since v12.0.0-alpha.0)
  • Fixed a crash when querying a mixed property with a string operator (contains/like/beginswith/endswith) or with case insensitivity. ([realm/realm-core#6376](realm/realm-core#6376, since v10.5.0)
  • Querying for equality of a string on an indexed mixed property was returning case insensitive matches. For example querying for myIndexedMixed == "Foo" would incorrectly match on values of "foo" or "FOO". (realm/realm-core#6376, since v10.5.0)
  • Adding an index to a mixed property on a non-empty class/objectType would crash with an assertion. (realm/realm-core#6376, since v10.5.0)
  • Realm.App.Sync#pause() could hold a reference to the database open after shutting down the sync session, preventing users from being able to delete the Realm. (realm/realm-core#6372, since v11.5.0)
  • Fixed a bug that may have resulted in Realm.Results and Realm.List being in different orders on different devices. Moreover, some cases of the error message Invalid prior_size may have be fixed too. (realm/realm-core#6191, since v10.15.0)
  • Exposed Sync as named export. #5649

Compatibility

  • React Native >= v0.71.0
  • Realm Studio v13.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

  • Enabled all tests from v11 and fixed all remaining failures. (#5595)
  • Fixed linting issues and running linting on CI.
  • Upgraded Realm Core from v13.6.0 to v13.8.0. (#5638)
  • Build iOS prebuilt binaries in release mode by default. (#5709)

Realm JavaScript v11.7.0

26 Mar 15:42
a44383a
Compare
Choose a tag to compare

Deprecations

  • Realm.App.Configuration#baseFilePath will be renamed in an upcoming major version. (#5630)

Enhancements

  • Performance improvement for the following queries (realm/realm-core#6376):
    • Significant (~75%) improvement when counting (Realm.Results#length) the number of exact matches (with no other query conditions) on a string/int/uuid/objectId property that has an index. This improvement will be especially noticiable if there are a large number of results returned (duplicate values).
    • Significant (~99%) improvement when querying for an exact match on a date property that has an index.
    • Significant (~99%) improvement when querying for a case insensitive match on a mixed property that has an index.
    • Moderate (~25%) improvement when querying for an exact match on a bool property that has an index.
    • Small (~5%) improvement when querying for a case insensitive match on a mixed property that does not have an index.

Fixed

  • Added a missing (internal) method on iOS. Building a React Native app will failed with the error Undefined symbol: realm::set_default_realm_file_directory(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >). (#5633, since v11.6.0)
  • Fixed a crash when querying a mixed property with a string operator (contains/like/beginswith/endswith) or with case insensitivity. ([realm/realm-core#6376](realm/realm-core#6376, since v10.5.0)
  • Querying for equality of a string on an indexed mixed property was returning case insensitive matches. For example querying for myIndexedMixed == "Foo" would incorrectly match on values of "foo" or "FOO". (realm/realm-core#6376, since v10.5.0)
  • Adding an index to a mixed property on a non-empty class/objectType would crash with an assertion. (realm/realm-core#6376, since v10.5.0)
  • Realm.App.Sync#pause() could hold a reference to the database open after shutting down the sync session, preventing users from being able to delete the Realm. (realm/realm-core#6372, since v11.5.0)
  • Fixed a bug that may have resulted in Realm.Results and Realm.List being in different orders on different devices. Moreover, some cases of the error message Invalid prior_size may have be fixed too. (realm/realm-core#6191, since v10.15.0)

Compatibility

  • React Native >= v0.71.4
  • Realm Studio v13.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

  • Upgraded Realm Core from v13.6.0 to v13.8.0. (#5640)

Realm JavaScript v11.6.0

23 Mar 17:43
32d480e
Compare
Choose a tag to compare

Enhancements

  • Added configuration option App.baseFilePath which controls where synced Realms and metadata is stored.

Fixed

  • Fix type error when using realm.create in combination with class base models. (since v11.0.0)

Compatibility

  • React Native >= v0.71.0
  • Realm Studio v13.0.0.
  • File format: generates Realms with format v23 (reads and upgrades file format v5 or later for non-synced Realm, upgrades file format v10 or later for synced Realms).

Internal

  • Test