Mapping Rule Filters
On this page
A mapping rule filter consists of a JavaScript
expression which evaluates each row of input data. The
column values from the row are available in the
columns["<column_name>"]
object.
During a sync job, Relational Migrator evaluates the expression for each row:
If the return value is
true
then the row is included in the migrated data.If the return value is
false
then the row is excluded.If the return value is not either, the row is excluded and an error is logged during migration.
Example
Below is an example of input documents and mapping rule JavaScript expressions that filter the data.
Filter Based on Field Value
The following example filters a document based on a single field value.
Relational input:
customer_id | company_name | address | city | postal_code | country | phone |
---|---|---|---|---|---|---|
ALFKI | Alfreds Futterkiste | Obere Str. 57 | Berlin | 12209 | Germany | 030-0074321 |
ANATR | Ana Trujillo Emparedados y helados | Avda. de la Constitución 2222 | México D.F. | 05021 | Mexico | 5-555-4729 |
ANTON | Antonio Moreno Taquería | Mataderos 2312 | México D.F. | 05023 | Mexico | 5-555-3932 |
Filter Expression:
columns["country"] == "Mexico"
MongoDB output:
[ { "customerId": "ANATR", "address": "Avda. de la Constitución 2222", "city": "México D.F.", "companyName": "Ana Trujillo Emparedados y helados", "country": "Mexico", "phone": "5-555-4729", "postalCode": "05021", }, { "customerId": "ANTON", "address": "Mataderos 2312", "city": "México D.F.", "companyName": "Antonio Moreno Taquería", "country": "Mexico", "phone": "5-555-3932", "postalCode": "05023", } ]