Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-284

Rename "partial" and "fullSynchronization" SyncConfiguration properties to "mode"

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None

      Goals

      A simpler configuration around synchronization modes.

      Expected Results

      Being able to open a Realm in either "query-based" or "full" mode.

      Actual Results

      We have two optional boolean configuration properties on the Realm.Sync.Configuration interface:

      partial

      > Whether this Realm should be opened in 'query-based synchronization' mode. Query-based synchronisation only synchronizes those objects that match the query specified in contrast to the normal mode of operation that synchronises all objects in a remote Realm.

      fullSynchronization

      > Whether this Realm should be opened in query-based or full synchronization mode. The default is query-based mode which only synchronizes objects that have been subscribed to.
      A fully synchronized Realm will synchronize the entire Realm in the background, irrespectively of the data being used or not.

      Proposed solution

      I propose we deprecate both the partial and fullSynchronization properties in favor of a third new property, called mode, as the two modes are mutually exclusive.

      The new mode property should be an optional string-based enum which (defaulting to "query-based"), taking a SyncMode as argument:

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      /**
       * The mode of synchronization which a Realm can be opened in.
       */
      enum SyncMode {
          /** Only synchronizes objects that have been subscribed to */
          QueryBased = "query-based",
          /** Synchronizes the entire Realm, irrespectively of the data being used or not */
          Full = "full",
      }
      

      Users can explicitly open in query-based mode using (which will be default):

      TypeScript

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      const realmConfig = user.createConfiguration({ sync: { mode: SyncMode.QueryBased } });
      const realm = new Realm(realmConfig);
      

      JavaScript

      const realmConfig = user.createConfiguration({ sync: { mode: "query-based" } });
      const realm = new Realm(realmConfig);
      

      Or alternatively the user can open in full mode using:

      TypeScript

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      const realmConfig = user.createConfiguration({ sync: { mode: SyncMode.Full } });
      const realm = new Realm(realmConfig);
      

      JavaScript

      const realmConfig = user.createConfiguration({ sync: { mode: "full" } });
      const realm = new Realm(realmConfig);
      

      Version of Realm and Tooling

      • Realm JS SDK Version: 2.25.0
      • Node or React Native: N/A
      • Client OS & Version: N/A
      • Which debugger for React Native: N/A

            Assignee:
            Unassigned Unassigned
            Reporter:
            kraen.hansen@mongodb.com Kræn Hansen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: