Skip to content

hendritjipto/realm-getstart

Repository files navigation

Realm Device Sync with NodeJS

Get start your Realm device sync with NodeJS. The NodeJS SDK it's a script based porgramming and it's simplify your development. To run your NodeJS you don't need to compile your application, make it roboust for faster prototyping and testing.

This application build on npm version 10.1.0 and node version 20.7.0

This sample app will demonstrate how the realm device sync permission and encryption works.

To simulate write into object please use Realm studio.

Create a free cluster on Atlas

  1. Please find the instruction here
  2. Create new application under app services createapp-new
  3. Make sure link your datasource to active cluster - free version is fine
  4. Popuplate your database with customuserdata -> customerdata.json and database with existing as collection name -> existing.json file can be found on monogodbdata
  5. Create a user on App Services create-user
  6. Setup the Rule permission. Click rule and select the realmdata database and existing collection. Use advance and copy past rule.json ! rule2
  7. Turn on role as query-able field
  8. Enable the device sync enablesync
Get start
  1. Make sure that you have NodeJS and npm installed on your computer. The easiest for windows use chocolatey and mac use homebrew
  2. To check your system please run npm --version and node --version
  3. Clone the repository
git clone https://github.com/hendritjipto/realm-getstart
  1. Run the npm init and npm install
npm init
npm install
  1. Change the app-id to your newly create app-id changeappid

Run as normal user

This will allow user to open certain document and have read-only permission

  1. Run the loginuser.js to test device sync
  2. A folder mongodb-realm will be created
  3. Realm database will be inside userid folder
  4. Open flx_sync_default.realm realm database with Realm studio

Run as manager user

This will allow user to all document and have read and write permission

  1. Run the loginmanager.js to test device sync
  2. A folder mongodb-realm will be created
  3. Realm database will be inside userid folder
  4. Open flx_sync_default.realm realm database with Realm studio

Run as encryted user realm

This will encrypt your realm database and have user permission

  1. When running the loginencrypt.js
  2. Copy this key 01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101
  3. A folder mongodb-realm will be created
  4. Realm database will be inside userid folder
  5. Open flx_sync_default.realm realm database with Realm studio
  6. Paste the key when Realm studio ask for the key
  7. The realm database will open

About

getting start with realm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published