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

Can't seem to manipulate data inside an 'in' statement #134

Open
fridaystreet opened this issue Mar 9, 2024 · 0 comments
Open

Can't seem to manipulate data inside an 'in' statement #134

fridaystreet opened this issue Mar 9, 2024 · 0 comments

Comments

@fridaystreet
Copy link

fridaystreet commented Mar 9, 2024

Maybe I'm going about this the wrong way, but I'm trying to essentially do a reverse comaprison. I have a data object with tags and I want to know if all the tags entered into the rule exist in the data

So I'm mapping the data out to it's singular value from the object and trying to compare all values passed by the user to be compared to make sure all the tags exist. It doesn't matter if the data has more tags, but as long as it has all the tags in the query

So I first filter out the data tags to leave only the tags the user is looking for, then my thought was, do an 'all' on the output of the filter to see if the output of the filter contiaisn all the tags.

Trying to get the follwing to work, but it just returns false

const data =  {
  tags: [
    {a: 1},
    {a: 2},
    {a: 3},
    {a: 4},
    {a: 5}
  ]
}

const  findTags = [1,2,3]

const rules = {

  all: [
    findTags,
    {
      in: [
        {var: ""},
        {
          map: [
            {
              filter: [
                { var: 'tags' },
                { in: [{ var: "a" }, findTags] }
              ]
            },
            { var: "a"}
          ]
        }
      ]
    }
  ]
}

console.log(jsonlogic.apply(rules, data))
@fridaystreet fridaystreet changed the title map appear to work inside 'in' Can't seem to manipulate data inside an 'in' statement Mar 9, 2024
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