-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy path4.all.js
41 lines (34 loc) · 1.08 KB
/
4.all.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* yod-mock
* https://github.com/qiu8310/yod-mock
*
* Copyright (c) 2015 Zhonglei Qiu
* Licensed under the MIT license.
*/
var yod = require('..');
// Create a type with fields which like database fields.
yod.type('User', {
name: {
first: '@First',
last: '@Last'
},
fullName: '@Self.name.first @First @Self.name.last', // refer 'name' property
chineseName: '@ChineseName',
age: '@Age(adult)', // call a type with argument
to100: '` 100 - @Self.age `', // execute javascript
children: '@First.repeat(1, 3)', // get an array
childrenCount: '@Self.children.length', // call js native property "length"
favouriteChild: '@Self.children.sample', // call lodash function "sample"
avatar: '@Avatar',
others: {
getSystemConfig: '@Config.system.video.hotbody.sample',
useParent: 'My name is @Parent.name.first.',
protection: 'Get firstName.length: ${@Parent.name.first}.length',
escape: 'You can escape caller \\@Parent.name.first.'
}
});
// Use the defined "User" type to create the random data.
yod({
status: 'ok',
users: '@User.repeat(10)'
});