-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransaction.js
More file actions
44 lines (37 loc) · 1.25 KB
/
transaction.js
File metadata and controls
44 lines (37 loc) · 1.25 KB
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
'use strict'
const mongoose = require('mongoose')
const { Client, Group } = require('./models')
const moment = require('moment-timezone')
const keygen = require('keygenerator')
function getId() {
let apiVersion = '4', status = 'PENDING'
const uniqKey = keygen._({ length: 15, forceUppercase: true })
const groupId = `G${apiVersion}V${moment.tz('Asia/Seoul').format('YYYYMMDDHHmmss')}${uniqKey}`
return groupId
}
async function start() {
try {
await mongoose.connect('mongodb://localhost/pm2test')
/*let clients= [ { "status": "PENDDING", "count": 0, } ]
for (let i = 0; i < 100000; i++) { clients.push(Object.assign({}, clients[0])) }
await Client.collection.insertMany(clients)*/
const types = ['sms', 'lms', 'mms', 'ata', 'cta']
const groups = []
for (let i = 0; i < 100000; i++) {
const groupId = getId()
groups.push({
_id: groupId,
groupId,
accountId: '12925149',
scheduledDate: moment().tz('Asia/Seoul').format('YYYY-MM-DD HH:mm:ss') ,
status: 'SCHEDULED',
count: Object.assign(...types.map(type => ({ [type]: 0 }))),
})
}
await Group.collection.insertMany(groups)
mongoose.connection.close()
} catch (err) {
console.log('err', err)
}
}
start()