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

Meta attribute property #1306

Merged
merged 5 commits into from
Mar 16, 2016
Merged

Meta attribute property #1306

merged 5 commits into from
Mar 16, 2016

Conversation

particlebanana
Copy link
Contributor

Part of the confusion and discussion about migrations has been that the attributes define properties in the physical storage layer. It's not ideal to continue adding adapter specific features to attribute definitions. This adds a reserved property to attribute definitions labeled meta that allows anything to be passed down to the adapter's registerConnection method.

The goal being that any adapter specific details can be defined and passed through. At the same time it cleans up the arguments being passed to registerConnection so that instead of trying to make sense of all the internal Waterline details you simple get a dictionary with the keys being the collection identity and each collection containing the following data:

  • definition - the normalized table definition that was already being used by adapters. This stays the same.
  • attributes - user defined attributes, including the meta field mentioned above.
  • meta - a pre-existing object that defined extra generated metadata about a collection, such as the fact that it is a junctionTable.

I would still like to move all migrations out of Waterline in future releases but this will continue to be part of the spec.

attributes: {
    email: {
      type: 'string',
      email: true,
      meta: {
        foo: 'bar',
        bar: function(hello) {
          return hello;
        }
      }
    }
  }

- no clone was happening on loadCollection so this now matches that behavior
- Adapters don't need to handle all of the internals of waterline, all they care about is the definition,
user attributes and any meta flags that have been sent in
@mikermcneil
Copy link
Member

Ooh man, so glad this still merges after what I just did. Very nice.

@particlebanana heads up- the callback from Validator.prototype.validate() now (finally) takes a first argument: err. Originally, async custom validations were added via a PR, which was no big deal. But since this was back before we were crotchety and jaded, it ended up getting moved around a bunch, and there was a throwing error that would crash the process. That's taken care of, relevant tests are updated, and luckily it is encapsulated by an interface that didn't require changing too many places in the code base.

Anyway, I was mainly just checking to be sure I didn't mess this PR up. And it looks like we're good.

particlebanana added a commit that referenced this pull request Mar 16, 2016
@particlebanana particlebanana merged commit 2a8daf3 into master Mar 16, 2016
@particlebanana particlebanana deleted the metaAttribute branch March 16, 2016 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants