Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-mckenna/b8142c5d39be7394c3df93d529dc8d92 to your computer and use it in GitHub Desktop.
Save michael-mckenna/b8142c5d39be7394c3df93d529dc8d92 to your computer and use it in GitHub Desktop.
'use strict'
const moment = require('moment');
const Realm = require('realm');
// these two lines were copied and pasted from the email sent me after registering for the free trial
var token = "***";
Realm.Sync.setAccessToken(token);
// TODO: make this admin key an environmental variable
const adminUser = Realm.Sync.User.adminUser('**');
const AppointmentSchema = {
name: 'Appointment',
primaryKey: 'id',
properties: {
id: 'string',
phoneNumber: 'string',
message: 'string',
time: {type: 'date', indexed: true}
}
};
// Appointment schema
class Appointment {
static sendNotifications() {
// set up realm. ********** IF USING THE REALM-JS LIB AND NOT realm-professional.tgz, IT FAILS HERE **************
let appointmentRealm = new Realm({
sync: {
user: adminUser,
url: "realm://***/appointments"
},
schema: [AppointmentSchema]
});
// ...more irrelevant code below....
}
}
Appointment.schema = AppointmentSchema;
module.exports = Appointment;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment