-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
utility.examples.js
125 lines (110 loc) · 3.29 KB
/
utility.examples.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
'use strict';
const { log } = require('./services');
const {
recordId,
fieldData,
transform,
containerData,
productInfo,
databases
} = require('../index.js');
//#record-id-utility--original-example
const extractRecordId = client =>
client
.find('Heroes', { name: 'yoda' }, { limit: 2 })
.then(response => response.data)
.then(result => log('record-id-utility-original-example', result));
//#
//#record-id-utility-example
const extractRecordIdOriginal = client =>
client
.find('Heroes', { name: 'yoda' }, { limit: 2 })
.then(response => recordId(response.data))
.then(result => log('record-id-utility-example', result));
//#
//#field-data-utility-original-example
const extractFieldDataOriginal = client =>
client
.find('Heroes', { name: 'yoda' }, { limit: 2 })
.then(response => response.data)
.then(result => log('field-data-utility-original-example', result));
//#
//#field-data-utility-example
const extractFieldData = client =>
client
.find('Heroes', { name: 'yoda' }, { limit: 2 })
.then(response => fieldData(response.data))
.then(result => log('field-data-utility-example', result));
//#
//#transform-utility-example
const transformData = client =>
client
.find('Transform', { name: 'Han Solo' }, { limit: 1 })
.then(result => transform(result.data))
.then(result => log('transform-utility-example', result));
//#
//
//#transform-utility-original-example
const transformDataOriginal = client =>
client
.find('Transform', { name: 'Han Solo' }, { limit: 1 })
.then(result => result.data)
.then(result => log('transform-utility-original-example', result));
//#
//#transform-utility-no-convert-example
const transformDataNoConvert = client =>
client
.find('Transform', { name: 'Han Solo' }, { limit: 1 })
.then(result => transform(result.data, { convert: false }))
.then(result => log('transform-utility-no-convert-example', result));
//#
//#container-data-example
const getContainerData = client =>
client
.find('Heroes', { imageName: '*' }, { limit: 1 })
.then(result =>
containerData(
result.data,
'fieldData.image',
'./assets',
'fieldData.imageName'
)
)
.then(result => log('container-data-example', result));
//#
//#product-info-utility-example
const getProductInfo = client =>
productInfo(process.env.SERVER).then(result =>
log('product-info-utility-example', result)
);
//#
//#databases-utility-example
const getDatabases = client =>
databases(process.env.SERVER).then(result =>
log('databases-utility-example', result)
);
//#
//#client-status-example
const getStatus = client =>
client.status().then(result => log('client-status-example', result));
//#
//#client-reset-example
const resetClient = client =>
client.reset().then(result => log('client-reset-example', result));
//#
const utilities = client =>
Promise.all([
extractFieldDataOriginal(client),
extractFieldData(client),
extractRecordIdOriginal(client),
extractRecordId(client),
transformDataOriginal(client),
transformData(client),
transformDataNoConvert(client),
getContainerData(client),
getProductInfo(client),
getDatabases(client),
getStatus(client),
resetClient(client)
]).then(responses => client);
module.exports = { utilities };