1 |
|
2 |
|
3 | var dream = require('./dream');
|
4 |
|
5 | var helloworld = dream.output();
|
6 | console.log(helloworld);
|
7 |
|
8 | dream.output(function (err, result) {
|
9 | console.log(result);
|
10 | });
|
11 |
|
12 | var data = dream
|
13 | .schema({
|
14 | name: String
|
15 | })
|
16 | .output();
|
17 |
|
18 | console.log(data);
|
19 |
|
20 | dream.schema('User', {
|
21 | name: String,
|
22 | age: Number
|
23 | });
|
24 |
|
25 | dream.schema('Location', {
|
26 | address: String,
|
27 | postcode: Number
|
28 | });
|
29 |
|
30 | dream
|
31 | .useSchema('Location')
|
32 | .output(function (err, result) {
|
33 | console.log(result);
|
34 | });
|
35 |
|
36 | dream.schema('User', {
|
37 | name: String
|
38 | });
|
39 |
|
40 | var data1 = dream
|
41 | .useSchema('User')
|
42 | .generate(3)
|
43 | .output();
|
44 |
|
45 | var data2 = dream
|
46 | .useSchema('User')
|
47 | .generateRnd(3)
|
48 | .output();
|
49 |
|
50 | console.log(data1);
|
51 | console.log(data2);
|
52 |
|
53 | dream.customType('pi', function () {
|
54 | return Math.PI;
|
55 | });
|
56 |
|
57 | dream.customType('hello', /hello+ (world|to you)/);
|
58 |
|
59 | dream
|
60 | .schema({
|
61 | name: 'name',
|
62 | age: 'age',
|
63 | address: 'address',
|
64 | contact: {
|
65 | phone: 'phone',
|
66 | servicePhone: /^(800[1-9]{6})$/
|
67 | },
|
68 | foo: function () {
|
69 | return 'bar';
|
70 | },
|
71 | pi: 'pi',
|
72 | hello: 'hello'
|
73 | })
|
74 | .generateRnd(2)
|
75 | .output(function (err, result) {
|
76 | console.log(result);
|
77 | });
|
78 |
|
79 | dream.customType('FiveWordsSentence', function (helper) {
|
80 | return helper.chance.sentence({words: 5});
|
81 | });
|
82 |
|
83 | dream
|
84 | .schema({
|
85 | phrase: 'FiveWordsSentence'
|
86 | })
|
87 | .generateRnd(2)
|
88 | .output(function (err, result) {
|
89 | console.log(result);
|
90 | });
|
91 |
|
92 | dream.customType('customTypeWithInput', function (helper) {
|
93 | return helper.input.value;
|
94 | });
|
95 |
|
96 | dream
|
97 | .input({value: 'Provided by an input'})
|
98 | .schema({
|
99 | result: 'customTypeWithInput'
|
100 | })
|
101 | .generateRnd()
|
102 | .output(function (err, result) {
|
103 | console.log(result);
|
104 | });
|
105 |
|
106 | dream.customType('iceCreamTruckDay', function (helper) {
|
107 | var businessDays = ['Monday', 'Wednesday', 'Friday'];
|
108 | return helper.oneOf(businessDays);
|
109 | });
|
110 |
|
111 | dream
|
112 | .schema({
|
113 | iceCreamDay: 'iceCreamTruckDay'
|
114 | })
|
115 | .generateRnd(2)
|
116 | .output(function (err, result) {
|
117 | console.log(result);
|
118 | });
|