Closed BryanBerger98 closed 3 months ago
Hi @BryanBerger98
Thanks for this. This is already supported by the MongoDB connector but not handled in the gateway :sweat_smile:
I can do it quite easily but in the meantime you can export your schema with the CLI and then import it to Azimutt in JSON, it should work.
For example: npx azimutt explort $mongo_url --mixed-json kind
.
I defined this attribute for the whole db, but maybe it's not good. Do you have some collection with it and some without it? Is it always the same attribute for all collections? If no, any idea how to get that input?
Cheers!
Hi @BryanBerger98
I deployed a new version of the gateway (0.1.7) which handle the discriminator.
You can add it to your connection url like: mongodb+srv://<user>:<pass>@<host>?discriminator=kind
Tell me how it goes ;)
Cheers!
With MongoDB, you can have multiple schemas assigned to the same model or key. This is called a discriminator. It needs a discrimination key to determine which schema should be used.
For example, imagine the User schema has a
role
key which can be used as a discrimination key. Theadmin
value assigned to therole
key allows us to use theAdminUserSchema
and thecustomer
value assigned to therole
key allows us to use theCustomerUserSchema
.The Mongoose docs explain it well: https://mongoosejs.com/docs/discriminators.html