-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.js
More file actions
75 lines (58 loc) · 1.93 KB
/
Copy pathinsert.js
File metadata and controls
75 lines (58 loc) · 1.93 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
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
const express = require('express')
const bodyParser = require('body-parser');
const cors = require('cors');
const app = express();
const port = 3000;
// Configuring body parser middleware
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
var AWS = require("aws-sdk");
AWS.config.update({
region: 'ap-south-1',
accessKeyId: 'AKIA3KZVSRWDBU2FCXN2',
secretAccessKey: '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',
endpoint: new AWS.Endpoint('dynamodb.ap-south-1.amazonaws.com'),
});
var docClient = new AWS.DynamoDB.DocumentClient();
app.post('/store', (req, res) => {
// We will be coding here
const data = req.body;
console.log(data['appId']);
var start = new Date().getTime();
console.log(start);
for (i = 22001; i <= 24000; i++) {
var table = "panelDynamo";
var params = {
TableName: table,
Item: {
"appId": "60ba619cdc52f500d37e810f",
"appIdid": i,
"appUserId": "2c0aa1dc1897b22d22f0973b",
"appUserIdid": i,
"notificationId": "a925f60e-21b8-4382-a4f2-51a2a86efe67",
"destinationId": "919744695571",
"destinationIdid": i,
"read": "Read",
"delivered": "Delivered",
"date": new Date().getTime()
}
}
console.log("Adding a new item...");
docClient.put(params, function (err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
}
var end = new Date().getTime();
var time = end - start;
console.log('Execution time: ' + time);
res.send('data added');
});
app.listen(port, () => {
console.log(`Example app listening on port ${port}!`)
});