Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a custom repository to store data into a relational database #57

Open
Heucles opened this issue Aug 6, 2017 · 1 comment
Open

Comments

@Heucles
Copy link

Heucles commented Aug 6, 2017

I am having some trouble placing a custom repository wiich would store data in a relational database which for the purposes of my system I have to keep updated the same way that I want to maintain the "mongo" repository updated, the best place for it to be set should be at the viewBuilder, using the callback?

Something like that?

module.exports = require('cqrs-eventdenormalizer').defineViewBuilder({
  name: 'itemCreated',
  id: 'payload.id'
}, function (data, vm, callback) {
  // assync logic to record data elsewhere
  //updating mongo database
  vm.set(data);

  recordOnRelationalDatabase(data).then(function (recordedData) {
    //...
    return callback();
  }),catch(function(err) {
    callback(err)
  });
});
@Heucles Heucles changed the title Create a custom repository to store data into the Create a custom repository to store data into a relational database Aug 6, 2017
@nanov
Copy link
Contributor

nanov commented Aug 7, 2017

vm.set is not updating the database ( still ), just the viewmodel object, the database is updated on commit internally.

Do you want to maintain two databases with exactly the same data ( RDBMS and NoSQL ), or just a RDBMS one?

For RDMS databases, one will have to write an own DB implementation for the wanted database like those here, for maintaining both you might want to write an implementation that does that internally, or run two denormalizers, one for each database ( again after having some RDBMS implementation ).

May I ask why would you want two databases with exactly the same viewmodel data, and why would you store such data in a relational database?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants