Every newly created object is getting deleted immediately even though I have 0 deletion code

ros

#1
- (void)syncConfig:(RLMSyncUser *)user {
    NSURL *syncServerURL = [NSURL URLWithString: REALM_SERVER_IMAGES];
    RLMRealmConfiguration *config = [user configurationWithURL:syncServerURL fullSynchronization:NO];

    [RLMRealm asyncOpenWithConfiguration:config
                           callbackQueue:dispatch_get_main_queue()
                                callback:^(RLMRealm *realm, NSError *error) {
                                    if (realm) {
                                        self.realm = realm;
                                        RLMResults *r = [JTFImage allObjectsInRealm:self.realm];
                                        self.token = [r addNotificationBlock:^(RLMResults * _Nullable results, RLMCollectionChange * _Nullable change, NSError * _Nullable error) {
                                            NSLog(@"results: %@", results);
                                            NSLog(@"insertions: %@", [change insertions]);
                                            NSLog(@"deletions: %@", [change deletions]);
                                        }];
                                        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                                            NSError *error;
                                            [self.realm transactionWithBlock:^{
                                                NSDictionary *d = @{@"uuid":@"blah",
                                                                    @"url":@"blah",
                                                                    @"text1":@"blah",
                                                                    @"text2":@"blah",
                                                                    @"text3":@"blah",
                                                                    @"isNew":@(YES),
                                                                    @"showScreen":@(YES),
                                                                    @"event":@"blah",
                                                                    @"created":[NSDate date],
                                                                    @"deviceID":@"blah"};
                                                NSLog(@"%@", d);
                                                [JTFImage createInRealm:self.realm withValue:d];
                                                //        [self.realm addOrUpdateObject:image];
                                            } error:&error];
                                            if(error) {
                                                NSLog(@"*********************Error: %@", error);
                                            }
                                        });
                                        
                                    } else {
                                        NSLog(@"%@", error);
                                    }
                                }];
}

Here’s my output

2018-08-21 00:14:03.007435-0700 MAC-JTF[336:19272] results: RLMResults <0x117d27270> (

)
2018-08-21 00:14:03.007515-0700 MAC-JTF[336:19272] insertions: (null)
2018-08-21 00:14:03.007548-0700 MAC-JTF[336:19272] deletions: (null)
2018-08-21 00:14:05.180083-0700 MAC-JTF[336:19272] {
created = “2018-08-21 07:14:05 +0000”;
deviceID = blah;
event = blah;
isNew = 1;
showScreen = 1;
text1 = blah;
text2 = blah;
text3 = blah;
url = blah;
uuid = blah;
}
2018-08-21 00:14:05.188488-0700 MAC-JTF[336:19272] results: RLMResults <0x117d27270> (
[0] JTFImage {
uuid = blah;
url = blah;
text1 = blah;
text2 = blah;
text3 = blah;
isNew = 1;
showScreen = 1;
event = blah;
created = 2018-08-21 07:14:05 +0000;
deviceID = blah;
}
)
2018-08-21 00:14:05.189114-0700 MAC-JTF[336:19272] insertions: (
0
)
2018-08-21 00:14:05.189246-0700 MAC-JTF[336:19272] deletions: (
)
2018-08-21 00:14:05.285446-0700 MAC-JTF[336:19272] results: RLMResults <0x117d27270> (

)
2018-08-21 00:14:05.285679-0700 MAC-JTF[336:19272] insertions: (
)
2018-08-21 00:14:05.285874-0700 MAC-JTF[336:19272] deletions: (
0
)

I don’t understand why Realm is deleting the object immediately after inserting. I checked realm studio, the object is still there. Can someone tell me why? Is this a catastrophic bug by realm cloud? I have yet to write any code that explicitly deletes any JTFImage objects

Cloud 3.9.11
Realm via cocoapods 3.7.6


#2

My best guess is that you’re using query-based synchronization, yet you have no subscriptions defined. Please review the docs for more details


#3

It could also be the database was a Fully sync’d database initially and now you need it to be partial (reference). You can change that in Realm Studio