Facing issue in using a schema in two microservices

Hi Team,

As I defined one schema in one of my microservice A, and now I want to use same schema in my another microservice B. And both microservices are using same shared database. But getting the below error, when trying to populate data using same schema from microservice B
MissingSchemaError: Schema hasn’t been registered for model “branchlocation”

Please share some suggestions
Thanks.

Hello @Arun_Sahani,

This is not related to MongoDB, This is also not related to microservice, It looks like you have not created the model for a particular schema.

Can you please elaborate with more details, like what backend language you are using, and any code example or repository you can share?

Hi @turivishal ,

Thanks for responding. I think, you didn’t understand the scenario. I was asking can we use any mongoose schema defined in microservice A into microservice B as both microservices are pointed to same shared database.

Regards,
Arun

Hi @Arun_Sahani,

Yes, we can use it, depending on your microservices setup.

1 Like