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

fix: createDatastorePredicate call was added #166

Merged
merged 1 commit into from
Oct 28, 2021

Conversation

frimfram
Copy link
Contributor

Description of changes:

The function call to createDataStorePredicate is added to convert predicate in object format to DateStore predicate format. An example of generated code:

 const filterCriteriaObj = {
    and: [
      {
        field: 'age',
        operand: '10',
        operator: 'gt',
      },
      {
        field: 'lastName',
        operand: 'L',
        operator: 'beginsWith',
      },
    ],
  };

  const filterCriteria = createDataStorePredicate(filterCriteriaObj);

  const { buttonUser } = useDataStoreBinding({
    type: 'collection', // returns zero or one or many records
    model: User,
    criteria: filterCriteria,
    pagination: buttonUserPagination
  });

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@alharris-at alharris-at requested review from alharris-at and dpilch and removed request for alharris-at October 28, 2021 00:08
Copy link
Contributor

@alharris-at alharris-at left a comment

Choose a reason for hiding this comment

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

You'll need to update snapshot tests as well.

Copy link
Contributor

@alharris-at alharris-at left a comment

Choose a reason for hiding this comment

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

Rather than creating the predicate declaration then compiled declaration statements, could you combine them into something like.

const buttonUserCondition = createDataStorePredicate({ <PREDICATE LITERAL> });

@frimfram
Copy link
Contributor Author

Rather than creating the predicate declaration then compiled declaration statements, could you combine them into something like.

const buttonUserCondition = createDataStorePredicate({ <PREDICATE LITERAL> });

Not sure what you are talking about here: can you provide examples?

@dpilch
Copy link
Contributor

dpilch commented Oct 28, 2021

He suggesting changing this:

 const filterCriteriaObj = {
    and: [
      {
        field: 'age',
        operand: '10',
        operator: 'gt',
      },
      {
        field: 'lastName',
        operand: 'L',
        operator: 'beginsWith',
      },
    ],
  };

  const filterCriteria = createDataStorePredicate(filterCriteriaObj);

To this:

  const filterCriteria = createDataStorePredicate({
    and: [
      {
        field: 'age',
        operand: '10',
        operator: 'gt',
      },
      {
        field: 'lastName',
        operand: 'L',
        operator: 'beginsWith',
      },
    ],
  });

@frimfram
Copy link
Contributor Author

He suggesting changing this:

 const filterCriteriaObj = {
    and: [
      {
        field: 'age',
        operand: '10',
        operator: 'gt',
      },
      {
        field: 'lastName',
        operand: 'L',
        operator: 'beginsWith',
      },
    ],
  };

  const filterCriteria = createDataStorePredicate(filterCriteriaObj);

To this:

  const filterCriteria = createDataStorePredicate({
    and: [
      {
        field: 'age',
        operand: '10',
        operator: 'gt',
      },
      {
        field: 'lastName',
        operand: 'L',
        operator: 'beginsWith',
      },
    ],
  });

That is a good suggestion, but we should do what's agreed with Hector and also that version gives more flexibility with what's passed to the function param.

@frimfram frimfram requested review from alharris-at and removed request for alharris-at October 28, 2021 17:33
@frimfram frimfram merged commit fbee20c into main Oct 28, 2021
@frimfram frimfram deleted the create-datastore-predicate branch October 28, 2021 17:44
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

Successfully merging this pull request may close these issues.

None yet

3 participants