1

I'm learning micro services architecture for NodeJs, as much i know about micro services is mentioned below:

  • ms architecture have different types of services.
  • each service will have it's own DB.
  • each service will contain full NodeJs project.
  • each service will communicate through calling API endpoints of each others.
  • each service should be able to deploy independently.

If anything is wrong or i missed up so please let me know.

My main question is like if we have 2 services, one is video service and another one is user service. Video service has model Videos and User service has model Users. Videos model will have a userId of the user who uploaded it. Now i want create an API which will return all the videos, each video object will have a sub object of user (who uploaded it) in behalf of that userId like given sample code. but now both Videos and Users model are exist on different databases, so how i can achieve this?

videosList: [ { id: 1, name: "Video 1", userId: 11, userObj: {...} }, { id: 2, name: "Video 2", userId: 20, userObj: {...} }, { id: 3, name: "Video 3", userId: 15, userObj: {...} }, ... ] 
9
  • You have to write services for inter communication between your microservices, like in video service you have to call user miccroservice for fetching user information.. Commented Jun 3, 2020 at 18:28
  • 1
    Read this full conversation https://stackoverflow.com/questions/30213456/transactions-across-rest-microservices Commented Jun 3, 2020 at 18:33
  • @turivishal b=how i can append a user sub object to the video object? because both DBs are different. Commented Jun 4, 2020 at 3:52
  • 1
    Microservices main concept is your microservices will communicate internally if you want but not DBs, You can exchange data through microservices not directly from DBs. Commented Jun 4, 2020 at 4:51
  • 1
    Yes we can make as much as needed.. Commented Jun 4, 2020 at 6:07

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.