-
Notifications
You must be signed in to change notification settings - Fork 16
/
utils.js
40 lines (34 loc) · 1.19 KB
/
utils.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
module.exports = {
getRandomValue: (length) => {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
},
getTestUserInsertStatements: (rowCount) => {
const sqlStatements = [];
for (let index = 0; index < rowCount; index++ ) {
const randomUsername = `${getRandomValue(5)}${index}`
// build the sql statement as an item in our array
sqlStatements.push(`
INSERT INTO thu_demo_user
(
username,
password,
date_created
)
VALUES
(
'${randomUsername}',
'test1001',
now()
);
`);
}
// flatten out the statements into on text with the SQL delimited between each statement
return sqlStatements.join(";");
}
}