Skip to content

Commit

Permalink
Feature/purge type (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
dekode-kevin authored Aug 3, 2023
1 parent eea7df4 commit 9451f84
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,28 +128,29 @@ Supposing you have a WordPress database and you need to modify certain meta, be

Each column stores a certain type of data, be it a name, username, email, etc. The `type` property in the config is used to define the type of data stored, and ultimately the type of random data to be inserted into the field. [https://github.com/dmgk/faker](https://github.com/dmgk/faker) is used for generating the fake data. These are the types currently supported:

| Type | Example output |
| --- | --- |
| `username` | `micah_pfeffer` |
| `password` | `5ccf672d5c73748146be6b37568efa57` |
| `email` | `[email protected]` |
| `url` | `http://sporerhamill.net/kyla.schmitt` |
| `name` | `Natasha Hartmann` |
| `firstName` | `Carolina` |
| `lastName` | `Kohler` |
| `phoneNumber` | `+49-131-0003060` |
| `addressFull` | `6071 Heaney Island Suite 553, Ebbaville Texas 37307` |
| `addressStreet` | `"586 Sylvester Turnpike"` |
| `addressPostCode` | `31340` |
| `addressCountry` | `Uruguay` |
| Type | Example output |
|------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `username` | `micah_pfeffer` |
| `password` | `5ccf672d5c73748146be6b37568efa57` |
| `email` | `[email protected]` |
| `url` | `http://sporerhamill.net/kyla.schmitt` |
| `name` | `Natasha Hartmann` |
| `firstName` | `Carolina` |
| `lastName` | `Kohler` |
| `phoneNumber` | `+49-131-0003060` |
| `addressFull` | `6071 Heaney Island Suite 553, Ebbaville Texas 37307` |
| `addressStreet` | `"586 Sylvester Turnpike"` |
| `addressPostCode` | `31340` |
| `addressCountry` | `Uruguay` |
| `paragraph` | `Lorem ipsum dolor sit amet, fabulas nostrum recteque vel ea, sit ut nemore similique. Ad per dicam molestie, nostro constituto duo ad. Ex scripta impedit cum, vidisse feugiat vivendum cum ad, cu liber senserit mediocrem pro.` |
| `shortString` | `wqFyJIrXYfVP7cLwqFyJIrXYfVP7cL` |
| `ipv4` | `121.204.82.227` |
| `companyName` | `Aufderhar LLC` |
| `companyNumber` | `123456789` |
| `creditCardNumber` | `1234-2121-1221-1211` |
| `creditCardExpiryDate` | `2015-11-11` |
| `creditCardType` | `mastercard` |
| `shortString` | `wqFyJIrXYfVP7cLwqFyJIrXYfVP7cL` |
| `ipv4` | `121.204.82.227` |
| `companyName` | `Aufderhar LLC` |
| `companyNumber` | `123456789` |
| `creditCardNumber` | `1234-2121-1221-1211` |
| `creditCardExpiryDate` | `2015-11-11` |
| `creditCardType` | `mastercard` |
| `purge` | |

If you need another type, please feel free to add support and file a PR!

Expand Down
5 changes: 5 additions & 0 deletions internal/helpers/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func GetFakerFuncs() map[string]func(*sqlparser.SQLVal) *sqlparser.SQLVal {
"creditCardNumber": generateCreditCardNumber,
"creditCardExpiryDate": generateCreditCardExpiryDate,
"creditCardType": generateCreditCardType,
"purge": generateEmptyString,
}

return fakerHelpers
Expand Down Expand Up @@ -116,3 +117,7 @@ func generateCompanyNumber(value *sqlparser.SQLVal) *sqlparser.SQLVal {
func generateShortString(value *sqlparser.SQLVal) *sqlparser.SQLVal {
return sqlparser.NewStrVal([]byte(faker.Lorem().Characters(30)))
}

func generateEmptyString(value *sqlparser.SQLVal) *sqlparser.SQLVal {
return sqlparser.NewStrVal([]byte(""))
}

0 comments on commit 9451f84

Please sign in to comment.