Super Simple Question iOS Swift Decoding Documents

Hey guys feeling quite dumb. Am new to MongoDB. Currently I’m moving a project of mine from Firebase to MongoDB, and do not want to take advantage of Realm. I strictly want to use MongoDB as shown here.

Question 1: Is this normal? Is this bad practice? I can’t seem to find a lot of StackOverflow posts of people using RealmSwift, and am getting very lost on trying to accomplish things.

Question 2: Here is a snippet of some code, a basic query I am performing.
Screen Shot 2022-02-17 at 7.48.12 PM

Here are the class object I have posted to MongoDB.
Screen Shot 2022-02-17 at 7.48.37 PM

Now here is where I have been ripping my hair out. In the query, (the first picture), once I have access to documents. Let’s say I want to turn each document into an object of class type Task. How do I do that???

I found this link where you can see decoding and encoding in Swift, but it is not doing those operations on a Document, but rather BSONDocument - entirely different things!

2 Likes