{
filter:{
"actor.name":{
$ne:"Rob C"
}
},
process:[
]
}
You can also append additional data. This adds an extension to all statements. Note that we must manually escape this extension name
{
filter:{
},
process:[
{
$addFields:{
"context.extensions.http://myExtension*`*com":"Some Value"
}
}
]
}
You can reference existing values, and modify them with expressions. This script makes the actor anonymous in a deterministic way.
{
filter:{
},
process:[
{
$addFields:{
"actor":{
"account":{
"homePage":"http://anonymous.com",
"name":{
$hash:"$actor"
}
}
}
}
}
]
}
You can use a switch expression to conditionally apply some transformation. This script makes the actor anonymous when the actor.name property is "Rob C". Otherwise, the actor is left as is.
{
filter:{
},
"process":[
{
"$addFields":{
"actor":{
"$switch":{
"branches": [
{
"case": { $eq: ["$actor.name", "Rob C"] }, then: { "account":{
"homePage":"http://anonymous.com",
"name":{
$hash:"$actor"
}
}}
},
],
"default": "$actor"
}
}
}
}
]
}
The below example filters the data. When statements are received, if they are any "actor.name" other than "Rob C", they will pass, either to the upstream, to the database (when attached to the write command on an access key), or the the API results (when attached to 'read'):
{
let out = [];
for(let i in $input)
{
if($input[i].actor.name !== "Rob C")
{
out.push($input[i])
}
}
$output = out;
}
You can also append additional data. This adds an extension to all statements. Note that we must manually escape this extension name, and that for simplicity's sake, this example destroys the existing extensions.
{
let out = [];
for(let i in $input)
{
$input[i].context = {
extensions: {
"http://myExtension*`*com" : "Some Value"
}
}
out.push($input[i])
}
$output = out;
}
You can reference existing values and modify them with expressions. This script makes the actor anonymous in a deterministic way.
{ let out = []; for(let i in $input) { $input[i].actor = { account:{ homePage:"http://anonymous.com", name: $hash($input[i].actor) } } out.push($input[i]) } $output = out; }