node.js – Mongoose Schemas and inserting via python
It is impossible because python and nodejs are 2 different runtimes – separate isolated processes which dont have access to each other memories.
Neither python nor mongo are aware about mongoose hooks. All queries to mongo are initiated on the client side – a script sends a request to modify state of the database or to query state of the database.
Change streams are not mongoose hooks but can be used to hook into the updates on mongo side. Its a bit more advanced use of the database. It comes with additional requirements for mongo set up, size of the oplog, availability of the changestream clients, error handling etc.
You can learn more about change streams here https://docs.mongodb.com/manual/changeStreams/ I would strongly recommend to seek professional advice to architect such set up to avoid frustration and unexpected behaviour.
Mongo itself does not support hooks as a feature,
mongoose gives you out of the box hooks you can use as youve mentioned. So what can you do to make it work in python?
Use an existing framework like pythons eve, eve gives you database hooks, much like
mongoosedoes. Now eve is a REST api framework which from your description doesnt sound like what youre looking for. Unfortunately I do not know of any package thats a perfect fit to your needs (if you do find one it would be great if you share a link in your question).
Build your own custom wrapper like this one. You can just built a custom wrapper class real quick and implement your own logic very easily.