Closed pacud closed 5 years ago
I cannot reproduce. :thinking:
$ cat << EOF | python3
from mongo_thingy import Thingy, registry
from mongo_thingy.versioned import Versioned
class Model(Versioned, Thingy):
pass
Model.add_index("key")
print(Model in registry)
EOF
True
I suppose that you have your model and your create_indexes
in two different files, and that the problem here simply is that your model hasn't been imported yet and thus its file hasn't been executed neither.
What if you add import your.model.module
before running create_indexes
?
That was exactly it.
Thanks.
Hey,
I have an API that uses mongo_thingy for its models in which I'm trying to add indexes the files look like this :
And I can't find the indexes in the database when launching my API. I've tried putting a breakpoing inside the
create_indexes
function and when printing the registry I have :So I'm thinking that this is the root cause, given that my model is not listed in the registry, there will be no index created for it.
How do I fix this ?