So I'm starting a journey down the road of microservices. I've spent some hours online trying immerse myself into this topic.
One concept I'm not quite grasping yet is the idea of not using SQL joins and therefore having a small independent database for authors and the same for books.
So I understand the following SQL:
BooksTable - id, name, authorid
AuthorsTable - id, name
select book.name, author.name from book
join author on book.authorId = author.id
In Node.js world
index.js
app.get('/api/books' bookDomain.get());
bookDomain.js
exports.get = () => {
const books = bookService.get();
const authors = authorService.get();
/*
This is where I'm lost: how do you achieve the simple SQL
above? I'm assuming in the domain is where this information is
"joined"? am I correct?
*/
};
Services
Database1
**bookService.js**
database context
Database2
**authorService.js**
database context
expected data (something like it, basically i'm saying JSON should be the return type)
[{
book {
"name": "Book 1",
"author": "Author Name 1"
}
},
{
book {
"name": "Book 2",
"author": "Author Name 2"
}
}]
from How do I resolve the authors names of books in microservice world?
No comments:
Post a Comment