Skip to content

Standardize adapter metadata passthrough #2

@TomFrost

Description

@TomFrost

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions