I am trying to do something like this question: Original Question
The thing that I am looking for is: I want to delcare my models before making connection with database. So, I want to keep my database connection session and the model separated and then make bridge in between when needed.
But in the answer of the link, the OP posted an answer in which I am not finding where the collection(...) function came from. Can anyone please help me in here? Is this something I have to import? If yes, then from where?
I tried in two ways: first, as a tuple
session.mapper(WikiPage, ("wiki_page", session))
It throws the error below:
AttributeError: 'tuple' object has no attribute 'm'
Then I tried passing as string without the session:
session.mapper(WikiPage, "wiki_page")
And faced similar type error:
AttributeError: 'str' object has no attribute 'm'
The thing is I noticed there is a field that it is looking for while I attempt to pass something as a collection(...) in the session.mapper():
File "/home/user_name/anaconda3/envs/dutch_law/lib/python3.11/site-packages/ming/odm/mapper.py", line 219, in _instrument_class
for fld in self.collection.m.fields:
^^^^^^^^^^^^^^^^^
Unfortunately, I don't know what is collection(...) here.