@pgpm/faker 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/Makefile +6 -0
- package/README.md +438 -0
- package/__tests__/faker.test.ts +135 -0
- package/deploy/schemas/faker/procedures/utils.sql +740 -0
- package/deploy/schemas/faker/schema.sql +8 -0
- package/deploy/schemas/faker/tables/cities/fixtures/1602987351008_fixture.sql +3700 -0
- package/deploy/schemas/faker/tables/cities/table.sql +29 -0
- package/deploy/schemas/faker/tables/dictionary/fixtures/1602969089665_fixture.sql +6036 -0
- package/deploy/schemas/faker/tables/dictionary/table.sql +17 -0
- package/jest.config.js +15 -0
- package/launchql-faker.control +8 -0
- package/launchql.plan +10 -0
- package/package.json +29 -0
- package/revert/schemas/faker/procedures/utils.sql +51 -0
- package/revert/schemas/faker/schema.sql +7 -0
- package/revert/schemas/faker/tables/cities/fixtures/1602987351008_fixture.sql +5 -0
- package/revert/schemas/faker/tables/cities/table.sql +7 -0
- package/revert/schemas/faker/tables/dictionary/fixtures/1602969089665_fixture.sql +5 -0
- package/revert/schemas/faker/tables/dictionary/table.sql +7 -0
- package/sql/launchql-faker--0.4.6.sql +10408 -0
- package/verify/schemas/faker/procedures/utils.sql +47 -0
- package/verify/schemas/faker/schema.sql +7 -0
- package/verify/schemas/faker/tables/cities/fixtures/1602987351008_fixture.sql +5 -0
- package/verify/schemas/faker/tables/cities/table.sql +7 -0
- package/verify/schemas/faker/tables/dictionary/fixtures/1602969089665_fixture.sql +5 -0
- package/verify/schemas/faker/tables/dictionary/table.sql +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
Copyright (c) 2025 Interweb, Inc.
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/Makefile
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
# @pgpm/faker
|
|
2
|
+
|
|
3
|
+
create fake data in PostgreSQL
|
|
4
|
+
|
|
5
|
+
# Usage
|
|
6
|
+
|
|
7
|
+
## state, city, zip
|
|
8
|
+
|
|
9
|
+
```sql
|
|
10
|
+
select faker.state();
|
|
11
|
+
-- CA
|
|
12
|
+
|
|
13
|
+
select faker.city();
|
|
14
|
+
-- Belle Haven
|
|
15
|
+
|
|
16
|
+
select faker.city('MI');
|
|
17
|
+
-- Livonia
|
|
18
|
+
|
|
19
|
+
select faker.zip();
|
|
20
|
+
-- 48105
|
|
21
|
+
|
|
22
|
+
select faker.zip('Los Angeles');
|
|
23
|
+
-- 90272
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## address, street
|
|
27
|
+
|
|
28
|
+
```sql
|
|
29
|
+
select faker.address();
|
|
30
|
+
-- 762 MESA ST
|
|
31
|
+
-- Fort Mohave, AZ 86427
|
|
32
|
+
|
|
33
|
+
select faker.address('MI');
|
|
34
|
+
-- 2316 LAPHAM WAY
|
|
35
|
+
-- Sterling Heights, MI 48312
|
|
36
|
+
|
|
37
|
+
select faker.street();
|
|
38
|
+
-- CLAY ST
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## tags
|
|
42
|
+
|
|
43
|
+
Tags can be seeded in `faker.dictionary` table, here's an example with sustainability
|
|
44
|
+
|
|
45
|
+
```sql
|
|
46
|
+
select faker.tags();
|
|
47
|
+
-- {"causes of global warming","electronic waste","solar powered cars"}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## words
|
|
51
|
+
|
|
52
|
+
```sql
|
|
53
|
+
select faker.word();
|
|
54
|
+
-- woodpecker
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Specify word types
|
|
58
|
+
|
|
59
|
+
```sql
|
|
60
|
+
select faker.word(ARRAY['adjectives']);
|
|
61
|
+
-- decisive
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## paragraphs
|
|
65
|
+
|
|
66
|
+
```sql
|
|
67
|
+
select faker.paragraph();
|
|
68
|
+
-- Ligula. Aliquet torquent consequat egestas dui. Nullam sed tincidunt mauris porttitor ad taciti rutrum eleifend. Phasellus.
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## email
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
select faker.email();
|
|
75
|
+
-- crimson79@hotmail.com
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## uuid
|
|
79
|
+
|
|
80
|
+
```sql
|
|
81
|
+
select faker.uuid();
|
|
82
|
+
-- 327cb21d-1680-47ee-9979-3689e1bcb9ab
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## tokens, passwords
|
|
86
|
+
|
|
87
|
+
```sql
|
|
88
|
+
select faker.token();
|
|
89
|
+
-- 9e23040a7825529beb1528c957eac73f
|
|
90
|
+
|
|
91
|
+
select faker.token(20);
|
|
92
|
+
-- 7504ef4eafbba04a9645198b10ebc9616afce13a
|
|
93
|
+
|
|
94
|
+
select faker.password();
|
|
95
|
+
-- d8f1cca306e4d7^15bb(62618c1e
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## hostname
|
|
99
|
+
|
|
100
|
+
```sql
|
|
101
|
+
select faker.hostname();
|
|
102
|
+
-- fine.net
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## time unit
|
|
106
|
+
|
|
107
|
+
```sql
|
|
108
|
+
select faker.time_unit();
|
|
109
|
+
-- hour
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## float
|
|
113
|
+
|
|
114
|
+
```sql
|
|
115
|
+
select faker.float();
|
|
116
|
+
-- 64.6970694223782
|
|
117
|
+
|
|
118
|
+
select faker.float(2.3,10.5);
|
|
119
|
+
-- 10.233102884792025
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## integer
|
|
123
|
+
|
|
124
|
+
```sql
|
|
125
|
+
select faker.integer();
|
|
126
|
+
-- 8
|
|
127
|
+
|
|
128
|
+
select faker.integer(2,10);
|
|
129
|
+
-- 7
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## date
|
|
133
|
+
|
|
134
|
+
```sql
|
|
135
|
+
select faker.date();
|
|
136
|
+
-- 2020-10-02
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Date 1-3 days ago
|
|
140
|
+
|
|
141
|
+
```sql
|
|
142
|
+
select faker.date(1,3);
|
|
143
|
+
-- 2020-12-02
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Date in the future between 1-3 days
|
|
147
|
+
|
|
148
|
+
```sql
|
|
149
|
+
select faker.date(1,3, true);
|
|
150
|
+
-- 2020-12-06
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## birthdate
|
|
154
|
+
|
|
155
|
+
```sql
|
|
156
|
+
select faker.birthdate();
|
|
157
|
+
-- 2007-02-24
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Generate birthdate for somebody who is between age of 37 and 64
|
|
161
|
+
|
|
162
|
+
```sql
|
|
163
|
+
select faker.birthdate(37, 64);
|
|
164
|
+
-- 1972-08-10
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## interval
|
|
168
|
+
|
|
169
|
+
```sql
|
|
170
|
+
select faker.interval();
|
|
171
|
+
-- 00:01:34.959831
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Generate an interval between 2 and 300 seconds
|
|
175
|
+
|
|
176
|
+
```sql
|
|
177
|
+
select faker.interval(2,300);
|
|
178
|
+
-- 00:01:04
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## gender
|
|
182
|
+
|
|
183
|
+
```sql
|
|
184
|
+
select faker.gender();
|
|
185
|
+
-- F
|
|
186
|
+
|
|
187
|
+
select faker.gender();
|
|
188
|
+
-- M
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## boolean
|
|
192
|
+
|
|
193
|
+
```sql
|
|
194
|
+
select faker.boolean();
|
|
195
|
+
-- TRUE
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## timestamptz
|
|
199
|
+
|
|
200
|
+
```sql
|
|
201
|
+
select faker.timestamptz();
|
|
202
|
+
-- 2019-12-20 15:57:29.520365+00
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Future timestamptz
|
|
206
|
+
|
|
207
|
+
```sql
|
|
208
|
+
select faker.timestamptz(TRUE);
|
|
209
|
+
-- 2020-12-03 23:00:10.013301+00
|
|
210
|
+
--
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## mime types
|
|
214
|
+
|
|
215
|
+
```sql
|
|
216
|
+
select faker.mime();
|
|
217
|
+
-- text/x-scss
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## file extensions
|
|
221
|
+
|
|
222
|
+
```sql
|
|
223
|
+
select faker.ext();
|
|
224
|
+
-- html
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
Specify a mimetype
|
|
228
|
+
|
|
229
|
+
```sql
|
|
230
|
+
select faker.ext('image/png');
|
|
231
|
+
-- png
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Image mimetypes
|
|
235
|
+
|
|
236
|
+
```sql
|
|
237
|
+
select faker.image_mime();
|
|
238
|
+
-- image/gif
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## image
|
|
242
|
+
|
|
243
|
+
```sql
|
|
244
|
+
select faker.image();
|
|
245
|
+
-- {"url": "https://picsum.photos/843/874", "mime": "image/gif"}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## profilepic
|
|
249
|
+
|
|
250
|
+
credit: thank you https://randomuser.me
|
|
251
|
+
|
|
252
|
+
```sql
|
|
253
|
+
select faker.profilepic();
|
|
254
|
+
-- {"url": "https://randomuser.me/api/portraits/women/53.jpg", "mime": "image/jpeg"}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Specify a gender
|
|
258
|
+
|
|
259
|
+
```sql
|
|
260
|
+
select faker.profilepic('M');
|
|
261
|
+
-- {"url": "https://randomuser.me/api/portraits/men/4.jpg", "mime": "image/jpeg"}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## file
|
|
265
|
+
|
|
266
|
+
```sql
|
|
267
|
+
select faker.file();
|
|
268
|
+
-- scarlet.jpg
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Specify a mimetype
|
|
272
|
+
|
|
273
|
+
```sql
|
|
274
|
+
select faker.file('image/png');
|
|
275
|
+
-- anaconda.png
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
## url
|
|
279
|
+
|
|
280
|
+
```sql
|
|
281
|
+
select faker.url();
|
|
282
|
+
-- https://australian.io/copper.gzip
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## upload
|
|
286
|
+
|
|
287
|
+
```sql
|
|
288
|
+
select faker.upload();
|
|
289
|
+
-- https://magenta.co/moccasin.yaml
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## attachment
|
|
293
|
+
|
|
294
|
+
```sql
|
|
295
|
+
select faker.attachment();
|
|
296
|
+
-- {"url": "https://silver.io/sapphire.jsx", "mime": "text/jsx"}
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
## phone
|
|
300
|
+
|
|
301
|
+
```sql
|
|
302
|
+
select faker.phone();
|
|
303
|
+
-- +1 (121) 617-3329
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## ip
|
|
307
|
+
|
|
308
|
+
```sql
|
|
309
|
+
select faker.ip();
|
|
310
|
+
-- 42.122.9.119
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## username
|
|
314
|
+
|
|
315
|
+
```sql
|
|
316
|
+
select faker.username();
|
|
317
|
+
-- amaranth28
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
## name
|
|
321
|
+
|
|
322
|
+
```sql
|
|
323
|
+
select faker.name();
|
|
324
|
+
-- Lindsay
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
Specify a gender
|
|
328
|
+
|
|
329
|
+
```sql
|
|
330
|
+
select faker.name('M');
|
|
331
|
+
-- Stuart
|
|
332
|
+
|
|
333
|
+
select faker.name('F');
|
|
334
|
+
-- Shelly
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## surname
|
|
338
|
+
|
|
339
|
+
```sql
|
|
340
|
+
select faker.surname();
|
|
341
|
+
-- Smith
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## fullname
|
|
345
|
+
|
|
346
|
+
```sql
|
|
347
|
+
select faker.fullname();
|
|
348
|
+
-- Ross Silva
|
|
349
|
+
|
|
350
|
+
select faker.fullname('M');
|
|
351
|
+
-- George Spencer
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## business
|
|
355
|
+
|
|
356
|
+
```sql
|
|
357
|
+
select faker.business();
|
|
358
|
+
-- Seed Partners, Co.
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
## longitude / latitude coordinates
|
|
362
|
+
|
|
363
|
+
```sql
|
|
364
|
+
select faker.lnglat( -118.561721, 33.59, -117.646374, 34.23302 );
|
|
365
|
+
-- (-118.33162189532844,34.15614699957491)
|
|
366
|
+
|
|
367
|
+
select faker.lnglat();
|
|
368
|
+
-- (-74.0205,40.316)
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
# Development
|
|
372
|
+
|
|
373
|
+
## start the postgres db process
|
|
374
|
+
|
|
375
|
+
First you'll want to start the postgres docker (you can also just use `docker-compose up -d`):
|
|
376
|
+
|
|
377
|
+
```sh
|
|
378
|
+
make up
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## install modules
|
|
382
|
+
|
|
383
|
+
Install modules
|
|
384
|
+
|
|
385
|
+
```sh
|
|
386
|
+
yarn install
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## install the Postgres extensions
|
|
390
|
+
|
|
391
|
+
Now that the postgres process is running, install the extensions:
|
|
392
|
+
|
|
393
|
+
```sh
|
|
394
|
+
make install
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
This basically `ssh`s into the postgres instance with the `packages/` folder mounted as a volume, and installs the bundled sql code as pgxn extensions.
|
|
398
|
+
|
|
399
|
+
## testing
|
|
400
|
+
|
|
401
|
+
Testing will load all your latest sql changes and create fresh, populated databases for each sqitch module in `packages/`.
|
|
402
|
+
|
|
403
|
+
```sh
|
|
404
|
+
yarn test:watch
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## building new modules
|
|
408
|
+
|
|
409
|
+
Create a new folder in `packages/`
|
|
410
|
+
|
|
411
|
+
```sh
|
|
412
|
+
lql init
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
Then, run a generator:
|
|
416
|
+
|
|
417
|
+
```sh
|
|
418
|
+
lql generate
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
You can also add arguments if you already know what you want to do:
|
|
422
|
+
|
|
423
|
+
```sh
|
|
424
|
+
lql generate schema --schema myschema
|
|
425
|
+
lql generate table --schema myschema --table mytable
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
## deploy code as extensions
|
|
429
|
+
|
|
430
|
+
`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.
|
|
431
|
+
|
|
432
|
+
## recursive deploy
|
|
433
|
+
|
|
434
|
+
You can also deploy all modules utilizing versioning as sqtich modules. Remove `--createdb` if you already created your db:
|
|
435
|
+
|
|
436
|
+
```sh
|
|
437
|
+
lql deploy awesome-db --yes --recursive --createdb
|
|
438
|
+
```
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { getConnections, PgTestClient } from 'pgsql-test';
|
|
2
|
+
|
|
3
|
+
let pg: PgTestClient;
|
|
4
|
+
let teardown: () => Promise<void>;
|
|
5
|
+
|
|
6
|
+
const objs = {
|
|
7
|
+
tables: {}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
({ pg, teardown } = await getConnections());
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
afterAll(async () => {
|
|
15
|
+
await teardown();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('gets random words', async () => {
|
|
19
|
+
const obj: Record<string, any> = {};
|
|
20
|
+
const types = [
|
|
21
|
+
'lnglat',
|
|
22
|
+
'address',
|
|
23
|
+
'state',
|
|
24
|
+
'city',
|
|
25
|
+
'file',
|
|
26
|
+
'tags',
|
|
27
|
+
'attachment',
|
|
28
|
+
'birthdate',
|
|
29
|
+
'profilepic'
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
for (const type of types) {
|
|
33
|
+
const { [type]: value } = await pg.one(`SELECT faker.${type}() AS ${type}`);
|
|
34
|
+
obj[type] = value;
|
|
35
|
+
}
|
|
36
|
+
console.log(obj);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('lnglat', async () => {
|
|
40
|
+
const obj: Record<string, any> = {};
|
|
41
|
+
const { lnglat } = await pg.one(`SELECT faker.lnglat() AS lnglat`);
|
|
42
|
+
obj['lnglat'] = lnglat;
|
|
43
|
+
|
|
44
|
+
const { lnglat: bbox } = await pg.one(
|
|
45
|
+
`SELECT faker.lnglat($1, $2, $3, $4) AS lnglat`,
|
|
46
|
+
[-118.561721, 33.59, -117.646374, 34.23302]
|
|
47
|
+
);
|
|
48
|
+
obj['bbox'] = bbox;
|
|
49
|
+
|
|
50
|
+
console.log(obj);
|
|
51
|
+
console.log(obj.bbox.y, ',', obj.bbox.x);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('tags', async () => {
|
|
55
|
+
const obj: Record<string, any> = {};
|
|
56
|
+
|
|
57
|
+
const { tags } = await pg.one(`SELECT faker.tags() AS tags`);
|
|
58
|
+
obj['tags'] = tags;
|
|
59
|
+
|
|
60
|
+
const { tag_with_min } = await pg.one(
|
|
61
|
+
`SELECT faker.tags($1, $2, $3) AS tag_with_min`,
|
|
62
|
+
[5, 10, 'tag']
|
|
63
|
+
);
|
|
64
|
+
obj['tag with min'] = tag_with_min;
|
|
65
|
+
|
|
66
|
+
const { face } = await pg.one(
|
|
67
|
+
`SELECT faker.tags($1, $2, $3) AS face`,
|
|
68
|
+
[5, 10, 'face']
|
|
69
|
+
);
|
|
70
|
+
obj['face'] = face;
|
|
71
|
+
|
|
72
|
+
console.log(obj);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('addresses', async () => {
|
|
76
|
+
const obj: Record<string, any> = {};
|
|
77
|
+
|
|
78
|
+
obj['any'] = (await pg.one(`SELECT faker.address() AS value`)).value;
|
|
79
|
+
obj['CA'] = (await pg.one(`SELECT faker.address($1) AS value`, ['CA'])).value;
|
|
80
|
+
obj['MI'] = (await pg.one(`SELECT faker.address($1) AS value`, ['MI'])).value;
|
|
81
|
+
obj['Los Angeles'] = (
|
|
82
|
+
await pg.one(`SELECT faker.address($1, $2) AS value`, ['CA', 'Los Angeles'])
|
|
83
|
+
).value;
|
|
84
|
+
|
|
85
|
+
console.log(obj);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
xit('mixed words and args', async () => {
|
|
89
|
+
const obj: Record<string, any> = {};
|
|
90
|
+
|
|
91
|
+
obj['english-words'] = (
|
|
92
|
+
await pg.one(
|
|
93
|
+
`SELECT faker.sentence($1, $2, $3, $4) AS value`,
|
|
94
|
+
['word', 7, 20, ['colors']]
|
|
95
|
+
)
|
|
96
|
+
).value;
|
|
97
|
+
|
|
98
|
+
obj['mixed-words'] = (
|
|
99
|
+
await pg.one(
|
|
100
|
+
`SELECT faker.sentence($1, $2, $3, $4) AS value`,
|
|
101
|
+
['word', 7, 20, ['colors', 'adjectives', 'surname', 'animals', 'stop']]
|
|
102
|
+
)
|
|
103
|
+
).value;
|
|
104
|
+
|
|
105
|
+
obj['sentence-words'] = (
|
|
106
|
+
await pg.one(
|
|
107
|
+
`SELECT faker.sentence($1, $2, $3, $4) AS value`,
|
|
108
|
+
['word', 7, 20, ['lorem']]
|
|
109
|
+
)
|
|
110
|
+
).value;
|
|
111
|
+
|
|
112
|
+
obj['sentence-chars'] = (
|
|
113
|
+
await pg.one(
|
|
114
|
+
`SELECT faker.sentence($1, $2, $3, $4) AS value`,
|
|
115
|
+
['char', 100, 140, ['lorem']]
|
|
116
|
+
)
|
|
117
|
+
).value;
|
|
118
|
+
|
|
119
|
+
obj['paragraph-chars'] = (
|
|
120
|
+
await pg.one(
|
|
121
|
+
`SELECT faker.paragraph($1, $2, $3, $4) AS value`,
|
|
122
|
+
['char', 300, 500, ['lorem']]
|
|
123
|
+
)
|
|
124
|
+
).value;
|
|
125
|
+
|
|
126
|
+
obj['integer-chars'] = (
|
|
127
|
+
await pg.one(`SELECT faker.integer($1, $2) AS value`, [300, 500])
|
|
128
|
+
).value;
|
|
129
|
+
|
|
130
|
+
obj['xenial'] = (
|
|
131
|
+
await pg.one(`SELECT faker.birthdate($1, $2) AS value`, [34, 39])
|
|
132
|
+
).value;
|
|
133
|
+
|
|
134
|
+
console.log(obj);
|
|
135
|
+
});
|