Remove item matching

Hi,

I try to remove item matching to a list, but i missing somthing maybe…
I mainly work with python and I try to adapt in javascript, sorry for the misunderstood.

sample of data :

{
    "_id": {
        "$oid": "625e651a5d42e768e006980c"
    },
    "date_created": {
        "$date": "2022-04-19T07:30:34.155Z"
    },
    "date_modified": {
        "$date": "2022-05-03T13:00:46.161Z"
    },
    "description": "",
    "custom_spec": {},
    "active": false,
    "name": "dupond jean",
    "first_name": "jean",
    "last_name": "dupond",
    "email": "[email protected]",
    "password": "fernet_key",
    "login": "loginname",
    "role": {
        "$oid": "625e5f450de4cbfd6ac368e9"
    }
}

Script part to clean unwanted item

const remove_users = new Set(["jean.dupond", "tata.yoyo"])

for (item of items){
  if (remove_users.has(item.json.login)){
    item.delete
  }
};

return items;

but “jean.dupond” and “tata.yoyo” wasn’t delete from items.
have you got an idea ?

thanks

const usersToRemove = ["jean.dupond", "tata.yoyo", "loginname"] // the field loginname needs to be filtered, thats why I added it to the list
return $input.all().filter(i => !usersToRemove.includes(i.json.login))
1 Like

Thank you !

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.