0

I am getting this error and can't seem to find any answer anywhere online. It is Swift 5.1 and Realm 3.19.1

Querying over backlinks is disabled but backlinks were found in the inverse relationship

I have two simple Realm Model objects, Todo and User.

@objcMembers class User: Object {
   dynamic var uid: String! = UUID().uuidString
   dynamic var username: String?
   dynamic var added: Date  = Date() // Date when user is added

   let todos = List<Todo>()
}

And:

@objcMembers class Todo: Object {    
   dynamic var title: String!
   dynamic var added = Date()

   let user = LinkingObjects(fromType: User.self, property: "todos")
}

And here I am calling the Todo objects:

var todos = realm.objects(Todo.self).filter("ANY user.uid CONTAINS [c]%@", uid)

Is there something I am doing wrong? Or somehow backlinks need to be activated somewhere before I can use them?

Realm documentation is of absolutely no help whatsoever.

enter image description here

What I am trying to do is to query all todo items for a given user by user id. Each User object has a list of Todo objects in it.

zeeshan
  • 4,913
  • 1
  • 49
  • 58
  • Two things - Your code works perfectly for me and presents the correct results. Second thing is that are you using .net or Xamarin frameworks as that's where the error appears to be from. – Jay Oct 20 '19 at 14:31
  • There is no .Net or Xamarin. I am using Swift 5.1 and Realm 3.19.1 – zeeshan Oct 21 '19 at 01:06
  • Well, as I mentioned, I literally created a new project, adding RealmSwift via the podfile and copy and pasted your code and it worked perfectly. I also ensured I matched your versions as well, Swift 5.1 and Realm 3.19.1. Are you using a podfile? Can you include that if so? Are you using Realm Cloud/Sync or working with a local Realm? – Jay Oct 21 '19 at 14:48
  • Thanks Jay. I am using Realm Cloud. And yes, using a podfile with simple line pod 'RealmSwift'. I'll try to do the same in a separate project like you did and see what I get. This is not my first Realm based app and I have used backlinks before successfully, but I have never seen this error before. – zeeshan Oct 21 '19 at 17:33

0 Answers0