This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SyncUser.logIn(with: credentials, | |
server: RealmURL.authentication, | |
timeout: 10) { user, error in | |
if let user = user { | |
print("Successfully signed in.") | |
let appDel = UIApplication.shared.delegate as! AppDelegate | |
appDel.initializeRealmConfigs() | |
let _ = RealmHelper.getRealmFor(configuration: RealmConfig.userObjectRealm!) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Starting function"); | |
// TODO: find a way to pull the admin_token.base64 without copying and pasting it | |
const Realm = require('realm'); | |
const adminUser = Realm.Sync.User.adminUser('******'); | |
const server_url = 'realm://****.com:9080'; | |
module.exports = function(changeEvent) { | |
console.log('Change detected at path: ' + changeEvent.path); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Logs: | |
Starting function | |
Changes in realm at: /globalUsers | |
Changes in Model: GlobalUser | |
- object inserted at position 4 : RealmObject { username: 'test', email: '[email protected]' } | |
Code: | |
console.log("Starting function"); | |
// add your initialization code here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log("Starting function"); | |
const Realm = require('realm'); | |
const adminUser = Realm.Sync.User.adminUser('**') | |
const server_url = 'realm://**'; | |
module.exports = function(changeEvent) { | |
console.log('Change detected at path: ' + changeEvent.path); | |
const changes = changeEvent.changes["UserSearch"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
const Realm = require('realm'); | |
// realm set up | |
const adminUser = Realm.Sync.User.adminUser('**'); | |
var token = "***"; | |
Realm.Sync.setAccessToken(token); | |
const AppointmentSchema = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CoreDataHelper { | |
// MARK: - Core Data Stack | |
lazy var applicationDocumentsDirectory: URL = { | |
let urls = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) | |
return urls[urls.count-1] | |
}() | |
lazy var managedObjectModel: NSManagedObjectModel = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static func searchUserBy(id: Int, in context: NSManagedObjectContext, completionHandler: @escaping (_ managedObjects: User?) -> Void) { | |
context.perform { | |
//searching core data | |
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "User") | |
request.returnsObjectsAsFaults = false | |
request.predicate = NSPredicate(format: "id == %@", "\(id)") | |
do { | |
let results = try context.fetch(request) | |
if let managedObjects = results as? [NSManagedObject], let user = managedObjects.first { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let privateContext = CoreDataStack.generatePrivateContext() | |
// 1. | |
privateContext.perform { | |
// 2. | |
for userJSON in jsonResponse { | |
let id = user["id"] as! Int | |
// 3. | |
self.searchUserBy(id: 0, in: privateContext) { (user) in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lastDoc: QueryDocumentSnapshot? | |
var listeners: [ListenerRegistration] = [] | |
var query: Query = db.collection("channels").document("the doc id for this channel").collection("messages").limit(to: 25) | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
addListener() // adds listener for first 25 messages | |
} | |
func scrollViewDidScroll(_ scrollView: UIScrollView) { |
OlderNewer