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

How to pass 'options' into the custom implementation of 'Store'? #27

Closed
nizachon opened this issue Jan 26, 2015 · 5 comments
Closed

How to pass 'options' into the custom implementation of 'Store'? #27

nizachon opened this issue Jan 26, 2015 · 5 comments

Comments

@nizachon
Copy link

Adriano,

Following your instructions (https://github.com/adrai/node-eventstore#own-db-implementation), I was able to have EventStore use my own implementation of Store.

But after being a happy camper for a few days, now I don't see a way to pass options into my Store's (and also, EventStore's) constructor.

https://github.com/adrai/node-eventstore/blob/master/index.js#L7 :

function getSpecificStore(options) {
  options = options || {};

  if (options.prototype instanceof Base) {
    return options;
  }

https://github.com/adrai/node-eventstore/blob/master/index.js#L48https://github.com/adrai/node-eventstore/blob/master/index.js#L48 :

module.exports = function(options) {
  options = options || {};

  var Store;

  try {
    Store = getSpecificStore(options);
  } catch (err) {
    throw err;
  }

  return new Eventstore(options, new Store(options));
};

module.exports.Store = Base;

It appears that when using the custom Store implementation the way you recommend, what gets passed as options into the factory method and EventStore constructor, is the constructor of the custom Store. Then the same Store constructor gets called with itself as the value of options...

Am I missing something here?

Thanks,
-Leo

@adrai
Copy link
Contributor

adrai commented Jan 27, 2015

ok, I see the problem... What do you think on having the "own implementation" as second argument?

@adrai
Copy link
Contributor

adrai commented Jan 27, 2015

No, this is a bad idea, this will break the api of some other cqrs modules... but we could do something like:

var es = require('eventstore')({
  type: Store,
  host: 'localhost'
});

adrai added a commit that referenced this issue Jan 27, 2015
@nizachon
Copy link
Author

I like it. Thank you!

@adrai adrai closed this as completed Jan 27, 2015
@nizachon
Copy link
Author

https://github.com/adrai/node-eventstore#own-db-implementation :

Shouldn't it be MyDB instead of Store:

var es = require('eventstore')({
  type: Store
});
// es.init...

@adrai
Copy link
Contributor

adrai commented Jan 28, 2015

Yes

Il giorno 27-gen-2015, alle ore 23:52, nizachon <notifications@gh.neting.ccmailto:notifications@github.com> ha scritto:

https://github.com/adrai/node-eventstore#own-db-implementation :

Shouldn't it be MyDB instead of Store:

var es = require('eventstore')({
type: Store
});
// es.init...

Reply to this email directly or view it on GitHubhttps://github.com//issues/27#issuecomment-71746966.

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