I’ve read a few similar posts here and the docs but I’m still missing something. I get the following error when trying to create/write my first Realm object to my DB:
RealmError: Cannot write to class Project when no flexible sync subscription has been created.
I was reading the Node SDK and just following along with it to understand how to create a subscription. I’m not sure I need to actually create a filtered subscription that looks for objects with current user’s ID in the owner field but I felt like that’s a reasonable way to get started.
I have no data in the DB for this object, this is my first attempt at running Realm. Thanks for any help… But, it seems I’m creating a subscription and I have flexible sync / dev mode enabled in the backend.
I did just test the initial subscriptions syntax that you’re using, and it appears to work. Can you also confirm the version of the realm SDK that you’re using?
Ok, I’ll give it a try. Also, what is the syntax to create a subscription that says “just give me all objects in a collection”. That would be more helpful right now as I learn Realm, how it works, verifying the collections/data I read/write from my app, etc…
When you say true predicate, you mean something like “1 == 1”, just any expression that evaluates to true so that I get access to all documents in a collection?
Since you’re new to Realm and really never used it before, I suggest starting work a local Realm first, and then once you have some experience with the Realm “ecossystem” expand into Flexible Sync and Sync’ing in general. Here’s a good starting place
My suggestion is because trying to wrap your brain around Flex Sync, and at the same time learning the SDK and usage can be somewhat overwhelming - especially when trying to determine what subscriptions you’ll actually need and what you won’t.
If you start with understanding Realm, when it comes time to plan your sync strategy, it will flow much easier and be less time consuming.
Ok excellent, moving the subs code into a step after the open, it now works. I verified that my test write (create a project object) worked and I can see it in my DB… very good.
Thanks a ton, pasting code below as it might help someone learning Realm as I am.
Thanks @Jay regarding ‘start slow’ advice. I agree… I’ll probably stop worrying about sync’ing to my Atlas instance for awhile and just try to pick up speed on how to CRUD locally with Realm, do queries, learn as I go, etc… But, I’ve spent the past couple weeks reading a ton and trying the basics so I’m getting past crawl phase at this point. Was a little bumpy but all new learning curves always are…