-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvipFilter.js
More file actions
43 lines (37 loc) · 975 Bytes
/
vipFilter.js
File metadata and controls
43 lines (37 loc) · 975 Bytes
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
const fs = require('fs')
let intermediaVipArr = []
let data = fs.readFileSync('hqusers.json', 'utf-8')
.split(/\r?\n/)
data.pop()
let vip = data.filter(
item => {
let jsonifyItem = JSON.parse(item)
return jsonifyItem.admin
}
)
vip.forEach(
item => {
let jsonifyItem = JSON.parse(item)
if (jsonifyItem.username === 'happypeter') {
return
}
let tempObj = {}
tempObj.type = 'vip'
tempObj.startDate = '2017-10-01'
tempObj.expireDate = '2018-10-01'
tempObj.total = ''
tempObj.userId = jsonifyItem._id
intermediaVipArr.push(tempObj)
}
)
console.log(intermediaVipArr.length)
let finalStr = intermediaVipArr.map(
item => JSON.stringify(item)
).join('\n')
fs.writeFile('vip.js', finalStr, (err) => {
if (err) throw err
console.log('The file has been restructured!')
})
// console.log(date.toLocaleDateString());
// mongoimport -d hqdata -c vip --file vip.js
// mongoexport -d hqdata -c vip -o ./vipdata.json