-
Notifications
You must be signed in to change notification settings - Fork 12
/
StoreData.js
39 lines (34 loc) · 990 Bytes
/
StoreData.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
/*
该程序用于将数据存储到LeanCloud平台
*/
var APP_ID = 'Me872SwKDBgiMyDLnneSS9T3-gzGzoHsz';
var APP_KEY = '8hyFXTocldzAvkPSr0i5ba0C';
var LC = require('leancloud-storage');
var fs = require('fs');
LC.init({
appId: APP_ID,
appKey: APP_KEY
});
var Data = LC.Object.extend('Data');
var str = fs.readFileSync(`${__dirname}\\files\\data.json`);
var obj = JSON.parse(str);
var i = 0;
for(let key in obj){
i++;
(function(interval){
setTimeout(() => {
let data = new Data();
data.set('lowerSalary', obj[key].lowerSalary);
data.set('higherSalary', obj[key].higherSalary);
data.set('name', obj[key].name);
data.set('city', obj[key].city);
data.set('count', obj[key].count);
data.save().then(() => {
console.log('Success...'+interval);
},
(e) => {
console.error(e);
});
}, interval * 1000);
})(i);
}