Filter Array
Keep only the items in a list that match your conditions. Supports AND/OR logic and comparisons like equals, greater than, and membership checks.
逻辑操作 逻辑
仅保留列表中匹配您条件的项目。支持 AND/OR 逻辑,以及等于、大于和成员检查等比较操作。
概览
| 字段 | 值 |
|---|---|
| 操作 ID | filter |
| 类别 | 逻辑 |
| 连接器 | 不需要 |
| 需要 gas | 否 |
| 资金移动 | 未声明 |
| 标签 | logic, filter, array, query, control-flow |
Payload 模式
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
array | array | 是 | 要过滤的对象数组 |
filter | object | 是 | 包含字段条件的带有 $and 或 $or 逻辑运算符的过滤 DSL。支持 $eq、$ne、$gt、$gte、$lt、$lte、$in、$nin 运算符。 |
结果模式
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
filtered | array | 是 | 匹配过滤器的过滤后数组项目 |
示例
json{ "type": "filter", "payload": { "array": [ { "id": "1", "amount": 1500, "status": "active" }, { "id": "2", "amount": 50, "status": "pending" } ], "filter": { "$and": [ { "status": { "$eq": "active" } }, { "amount": { "$gte": 1000 } } ] } }, "children": []}
bashcurl -X POST "https://api.b3os.org/v1/actions/filter/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "array": [ { "id": "1", "amount": 1500, "status": "active" }, { "id": "2", "amount": 50, "status": "pending" } ], "filter": { "$and": [ { "status": { "$eq": "active" } }, { "amount": { "$gte": 1000 } } ] } }}'
负载字段可以使用工作流表达式,例如 {{$trigger.body.amount}}、{{$nodes.fetch.result.price}} 和 {{$props.asset}},当值应来自触发器、先前节点或可重用工作流属性时。
