How might the architecture look if the data layer is a 3rd party API?
Should not be so different.
A wrapper class needs to be written for every API resource, with a compatible interface across all models.
class UserModel(){ public UpdateOne(obj: { selector: any, update: any }):Promise<any> { // ...API Call } }
Some methods, for example, UpdateMany may not be present in some third-party API resources and so a custom logic needs to be written.
UpdateMany
class CompanyModel(){ public UpdateOne(obj: { selector: any, update: any }):Promise<any> { // ...API Call } public UpdateMany(objs: Array<{ selector: any, update: any }>):Promise<Array<any>> { return Promise.all( updates.map(u => { return this.UpdateOne(u.selector, u.update); }) ) } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
How might the architecture look if the data layer is a 3rd party API?
Should not be so different.
A wrapper class needs to be written for every API resource, with a compatible interface across all models.
Some methods, for example,
UpdateMany
may not be present in some third-party API resources and so a custom logic needs to be written.