From 173bcede24446d72814e76afcba69d5183691a8d Mon Sep 17 00:00:00 2001 From: Jessica Ulyate Date: Wed, 14 Mar 2018 14:05:42 +0100 Subject: [PATCH 1/2] Slight modification to configuration file options formatting --- README.md | 106 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index c086fc3..303293a 100644 --- a/README.md +++ b/README.md @@ -22,9 +22,10 @@ Klepto is a tool that copies and anonymises data from other sources. - [Usage](#usage) - [Steal Options](#steal-options) - [Configuration File Options](#configuration-file-options) - - [Relationships](#relationships) + - [IgnoreData](#ignoredata) - [Matchers](#matchers) - - [Anonymisation](#anonymisation) + - [Anonymise](#anonymise) + - [Relationships](#relationships) - [Examples](#examples) - [Contributing](#contributing) - [License](#licence) @@ -123,47 +124,33 @@ We recommend to always set the following parameters: ## Configuration File Options -You can set a number of keys in the configuration file. Here is the list of all configuration options: -- `Matchers` are variables to store filter data, you can declare a filter once and reuse it among tables. -- `Tables` represents a klepto table definition. - - `Name` is the table name. - - `IgnoreData` if set to true, it will dump the table structure without importing data. - - `Filter` represents the way you want to filter the results. - - `Match` is a condition field to dump only certain amount data. - - `Limit` defines a limit of results to be fetched. - - `Sorts` is the sort condition for the table. - - `Anonymise` anonymise columns. - - `Relationships` represents the relationship between the table and referenced table. - - `Table` is the table name. - - `ForeignKey` is the table name foreign key. - - `ReferencedTable` is the referenced table name. - - `ReferencedKey` is the referenced table primary key name. +You can set a number of keys in the configuration file. Below is a list of all configuration options, followed by some examples of specific keys. + +- `Matchers` - Variables to store filter data. You can declare a filter once and reuse it among tables. +- `Tables` - A Klepto table definition. + - `Name` - The table name. + - `IgnoreData` - A flag to indicate whether data should be imported or not. If set to true, it will dump the table structure without importing data. + - `Filter` - A Klepto definition to filter results. + - `Match` - A condition field to dump only certain amount data. The value should correspond to an existing `Matchers` definition. + - `Limit` - The number of results to be fetched. + - `Sorts` - Defines how the table is sorted. + - `Anonymise` - Indicates which columns to anonymise. + - `Relationships` - Represents a relationship between the table and referenced table. + - `Table` - The table name. + - `ForeignKey` - The table's foreign key. + - `ReferencedTable` - The referenced table name. + - `ReferencedKey` - The referenced table primary key. - -### Relationships -The `Relationships` key represents a relationship definition between tables. -#### Example -Dump the latest 100 users with their orders: -```toml -[[Tables]] - Name = "users" - [Tables.Filter] - Limit = 100 - [Tables.Filter.Sorts] - created_at = "desc" + +### IgnoreData + +You can dump the database structure without importing data by setting the `IgnoreData` value to `true`. +```toml [[Tables]] - Name = "orders" - [[Tables.Relationships]] - # behind the scenes klepto will create a inner join between orders and users - ForeignKey = "user_id" - ReferencedTable = "users" - ReferencedKey = "id" - [Tables.Filter] - Limit = 100 - [Tables.Filter.Sorts] - created_at = "desc" + Name = "logs" + IgnoreData = true ``` @@ -190,18 +177,9 @@ Matchers are variables to store filter data. You can declare a filter once and r See [examples](./examples) for more. - -### Ignore data - -You can dump the database structure without importing data by setting the `IgnoreData` value to `true`. -```toml -[[Tables]] - Name = "logs" - IgnoreData = true -``` - -### Anonymisation + +### Anonymise You can anonymise specific columns in your table using the `Anonymise` key. Anonymisation is performed by running a Faker against the specified column. @@ -232,6 +210,34 @@ $ go get github.com/ungerik/pkgreflect $ fake master pkgreflect -notypes -novars -norecurs vendor/github.com/icrowley/fake/ ``` + +### Relationships +The `Relationships` key represents a relationship between the table and referenced table. + +To dump the latest 100 users with their orders: +```toml +[[Tables]] + Name = "users" + [Tables.Filter] + Limit = 100 + [Tables.Filter.Sorts] + created_at = "desc" + +[[Tables]] + Name = "orders" + [[Tables.Relationships]] + # behind the scenes klepto will create a inner join between orders and users + ForeignKey = "user_id" + ReferencedTable = "users" + ReferencedKey = "id" + [Tables.Filter] + Limit = 100 + [Tables.Filter.Sorts] + created_at = "desc" +``` + + + ## Examples From b0986bf0eb5567dfc5c5e92be6400715dd205b83 Mon Sep 17 00:00:00 2001 From: Jessica Ulyate Date: Wed, 14 Mar 2018 14:11:51 +0100 Subject: [PATCH 2/2] Updated formatting for Configuration file options --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 303293a..ce65b5a 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ You can set a number of keys in the configuration file. Below is a list of all c - `Anonymise` - Indicates which columns to anonymise. - `Relationships` - Represents a relationship between the table and referenced table. - `Table` - The table name. - - `ForeignKey` - The table's foreign key. + - `ForeignKey` - The table's foreign key. - `ReferencedTable` - The referenced table name. - `ReferencedKey` - The referenced table primary key.