Skip to content

Latest commit

 

History

History
117 lines (77 loc) · 2.1 KB

Functions.md

File metadata and controls

117 lines (77 loc) · 2.1 KB

Filtering/Transformation functions

Functions are represented as a string with the following format:

<source>.<namespace>.<func_name>-<arg1>-<arg2>...
  • Function can accept or require arguments.

  • The source represent the function origin. Could be pgfilter, faker

  • namespace: Function category based on the source

Sources

pgfilter

Builtin internal helpfull functions

default

pgfilter.default.nul

Replace the current value of the column by NULL( Postgres representation \N)

  • Column type: anything

  • Column must accept nul as a valid value

  • Example:

     {
     	"public.requests" : {
     		"payload": "pgfilter.default.nul"
     	}
     }
pgfilter.default.zlen

Replace the current value of the column by an empty string

  • Column type: varchar/text

  • Column must accept empty strings as valid value

  • Example:

     {
     	"public.requests" : {
     		"encoded_secret": "pgfilter.default.zlen"
     	}
     }
pgfilter.default.zlar

Replace the current value of the column by an empty array

  • Column type: array

  • Example:

     {
     	"public.requests" : {
     		"ips": "pgfilter.default.zlar"
     	}
     }

filter

pgfilter.filter.fnow-<dur>

Evaluate the column value against the dur argument. If column value match the duration, the row is allowed to restore. Otherwise, the whole row is ignored and won't be included in the restore.

  • Column type: timestamp

  • Arguments:

  • Example:

    For 60 days from now

     {
     	"public.requests" : {
     		"created": "pgfilter.filter.fnow-P60D" // 60 days of duration on the column
     	}
     }

NOTE fnow does not support Week duration yet. eg P1W

faker

All the functions on faker.js API are available.

For example:

  • faker.person.firstName
  • faker.person.middleName
  • faker.company.name
  • faker.number.int
  • faker.internet.password

For more information. Check faker API methods