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

Standardize adapter metadata passthrough #2

Open
TomFrost opened this issue Feb 15, 2016 · 0 comments
Open

Standardize adapter metadata passthrough #2

TomFrost opened this issue Feb 15, 2016 · 0 comments

Comments

@TomFrost
Copy link

Currently, some adapters pass back the written object on update() or create(), while others pass back a DB response object with metadata (here's looking at you, MySQL).

While the MySQL adapter could be fixed to pass back the written object, the meta information is valuable. I see two clear options for this:

  • Symbols. Modli could export const meta = Symbol.for('modli.meta'), and metadata could be accessed by accessing either resolvedObject[modli.meta] or resolvedObject[Symbol.for('modli.meta')]
  • For better support with non-ES6, a non-enumerable _meta property could be defined with Object.defineProperty(objToBeResolved, '_meta', {value: metaDataObj}). The only issue there is that it would overwrite the _meta key if it legitimately existed on the target object.

Edit: For clarity, if the second method is chosen, the only change necessary to modli core would be documentation to standardize the convention.

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

1 participant