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.
- Please find the instruction here
- Create new application under app services
- Make sure link your datasource to active cluster - free version is fine
- Popuplate your database with
customuserdata -> customerdata.json
anddatabase with existing as collection name -> existing.json
file can be found on monogodbdata - Create a user on App Services
- Setup the Rule permission. Click rule and select the realmdata database and existing collection. Use advance and copy past
rule.json
! - Turn on role as query-able field
- Enable the device sync
- Make sure that you have NodeJS and npm installed on your computer. The easiest for windows use chocolatey and mac use homebrew
- To check your system please run npm --version and node --version
- Clone the repository
git clone https://github.com/hendritjipto/realm-getstart
- Run the npm init and npm install
npm init
npm install
This will allow user to open certain document and have read-only permission
- Run the
loginuser.js
to test device sync - A folder mongodb-realm will be created
- Realm database will be inside
userid
folder - Open
flx_sync_default.realm
realm database with Realm studio
This will allow user to all document and have read and write permission
- Run the
loginmanager.js
to test device sync - A folder mongodb-realm will be created
- Realm database will be inside
userid
folder - Open
flx_sync_default.realm
realm database with Realm studio
This will encrypt your realm database and have user permission
- When running the
loginencrypt.js
- Copy this key
01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101
- A folder mongodb-realm will be created
- Realm database will be inside
userid
folder - Open
flx_sync_default.realm
realm database with Realm studio - Paste the key when Realm studio ask for the key
- The realm database will open