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

adding ability to select fields, on single resource only for now #39

Merged
merged 3 commits into from
Feb 26, 2019

Conversation

aklkv
Copy link
Contributor

@aklkv aklkv commented Feb 26, 2019

fixes: #25

@aklkv aklkv added the enhancement New feature or request label Feb 26, 2019
@aklkv aklkv self-assigned this Feb 26, 2019
@@ -51,9 +61,13 @@ export default class KnexProcessor<
const { id, type } = ref;
const tableName = this.typeToTableName(type);
const filters = params ? { id, ...(params.filter || {}) } : { id };
const Resource = Object.create(this.resourceFor(type));
const resource = Object.create(this.resourceFor(type));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using Object.create?

const resource = Object.create(this.resourceFor(type));
const fields = params ? { ...params.fields } : {};
const attributes = getAttributes(
Object.keys(resource.__proto__.attributes),
Copy link
Contributor

@ebryn ebryn Feb 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like if we didn't use Object.create we could just be doing something like:

const Resource = this.resourceFor(type);
// ...
Object.keys(Resource.prototype.attributes)

@ebryn ebryn merged commit 320b6d9 into master Feb 26, 2019
@ebryn ebryn deleted the feature/fields branch February 26, 2019 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fields / sparse fieldsets
2 participants