0.4.6 • Published 3 years ago

@launchql/faker v0.4.6

Weekly downloads
11
License
-
Repository
-
Last release
3 years ago

faker Build Status

create fake data in PostgreSQL

Usage

state, city, zip

select faker.state();
-- CA

select faker.city();
-- Belle Haven

select faker.city('MI');
-- Livonia

select faker.zip();
-- 48105

select faker.zip('Los Angeles');
-- 90272

address, street

select faker.address();
-- 762 MESA ST         
-- Fort Mohave, AZ 86427

select faker.address('MI');
-- 2316 LAPHAM WAY           
-- Sterling Heights, MI 48312

select faker.street();
-- CLAY ST

tags

Tags can be seeded in faker.dictionary table, here's an example with sustainability

select faker.tags();
-- {"causes of global warming","electronic waste","solar powered cars"}

words

select faker.word();
-- woodpecker

Specify word types

select faker.word(ARRAY['adjectives']);
-- decisive

paragraphs

select faker.paragraph();
-- Ligula. Aliquet torquent consequat egestas dui. Nullam sed tincidunt mauris porttitor ad taciti rutrum eleifend. Phasellus.

email

select faker.email();
-- crimson79@hotmail.com

uuid

select faker.uuid();
-- 327cb21d-1680-47ee-9979-3689e1bcb9ab

tokens, passwords

select faker.token();
-- 9e23040a7825529beb1528c957eac73f

select faker.token(20);
-- 7504ef4eafbba04a9645198b10ebc9616afce13a

select faker.password();
-- d8f1cca306e4d7^15bb(62618c1e

hostname

select faker.hostname();
-- fine.net

time unit

select faker.time_unit();
-- hour

float

select faker.float();
-- 64.6970694223782

select faker.float(2.3,10.5);
-- 10.233102884792025

integer

select faker.integer();
-- 8

select faker.integer(2,10);
-- 7

date

select faker.date();
-- 2020-10-02

Date 1-3 days ago

select faker.date(1,3);
-- 2020-12-02

Date in the future between 1-3 days

select faker.date(1,3, true);
-- 2020-12-06

birthdate

select faker.birthdate();
-- 2007-02-24

Generate birthdate for somebody who is between age of 37 and 64

select faker.birthdate(37, 64);
-- 1972-08-10

interval

select faker.interval();
-- 00:01:34.959831

Generate an interval between 2 and 300 seconds

select faker.interval(2,300);
-- 00:01:04

gender

select faker.gender();
-- F

select faker.gender();
-- M

boolean

select faker.boolean();
-- TRUE

timestamptz

select faker.timestamptz();
-- 2019-12-20 15:57:29.520365+00

Future timestamptz

select faker.timestamptz(TRUE);
-- 2020-12-03 23:00:10.013301+00
-- 

mime types

select faker.mime();
-- text/x-scss

file extensions

select faker.ext();
-- html

Specify a mimetype

select faker.ext('image/png');
-- png

Image mimetypes

select faker.image_mime();
-- image/gif

image

select faker.image();
-- {"url": "https://picsum.photos/843/874", "mime": "image/gif"}

profilepic

credit: thank you https://randomuser.me

select faker.profilepic();
-- {"url": "https://randomuser.me/api/portraits/women/53.jpg", "mime": "image/jpeg"}

Specify a gender

select faker.profilepic('M');
-- {"url": "https://randomuser.me/api/portraits/men/4.jpg", "mime": "image/jpeg"}

file

select faker.file();
-- scarlet.jpg

Specify a mimetype

select faker.file('image/png');
-- anaconda.png

url

select faker.url();
-- https://australian.io/copper.gzip

upload

select faker.upload();
-- https://magenta.co/moccasin.yaml

attachment

select faker.attachment();
--  {"url": "https://silver.io/sapphire.jsx", "mime": "text/jsx"}

phone

select faker.phone();
-- +1 (121) 617-3329

ip

select faker.ip();
-- 42.122.9.119

username

select faker.username();
-- amaranth28

name

select faker.name();
-- Lindsay

Specify a gender

select faker.name('M');
-- Stuart

select faker.name('F');
-- Shelly

surname

select faker.surname();
-- Smith

fullname

select faker.fullname();
-- Ross Silva

select faker.fullname('M');
-- George Spencer

business

select faker.business();
-- Seed Partners, Co.

longitude / latitude coordinates

select faker.lnglat( -118.561721, 33.59, -117.646374, 34.23302 );
-- (-118.33162189532844,34.15614699957491)

select faker.lnglat();
-- (-74.0205,40.316)

Development

start the postgres db process

First you'll want to start the postgres docker (you can also just use docker-compose up -d):

make up

install modules

Install modules

yarn install

install the Postgres extensions

Now that the postgres process is running, install the extensions:

make install

This basically sshs into the postgres instance with the packages/ folder mounted as a volume, and installs the bundled sql code as pgxn extensions.

testing

Testing will load all your latest sql changes and create fresh, populated databases for each sqitch module in packages/.

yarn test:watch

building new modules

Create a new folder in packages/

lql init

Then, run a generator:

lql generate

You can also add arguments if you already know what you want to do:

lql generate schema --schema myschema
lql generate table --schema myschema --table mytable

deploy code as extensions

cd into packages/<module>, and run lql package. This will make an sql file in packages/<module>/sql/ used for CREATE EXTENSION calls to install your sqitch module as an extension.

recursive deploy

You can also deploy all modules utilizing versioning as sqtich modules. Remove --createdb if you already created your db:

lql deploy awesome-db --yes --recursive --createdb
0.4.5

3 years ago

0.4.4

3 years ago

0.3.5

3 years ago

0.4.6

3 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.4.3

3 years ago

0.3.4

3 years ago

0.4.2

3 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.1.30

3 years ago

0.1.29

3 years ago

0.2.0

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.18

3 years ago

0.1.17

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.10

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.0

3 years ago