Skip to content

Commit 21cbe83

Browse files
authored
Merge pull request #23 from Mala1180/feature/init-db
init db scripts for alarm, monitoring and auth services
2 parents 0684130 + 5a9293a commit 21cbe83

File tree

3 files changed

+82
-30
lines changed

3 files changed

+82
-30
lines changed

alarm/db/alarm-init.js

Lines changed: 57 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ db.createCollection('anomaly')
44

55
db.anomaly.insert([
66
{
7-
_id: {
8-
$oid: '65b514200718dbb3580fb9e6'
9-
},
7+
_id: '65b514200718dbb3580fb9e6',
108
deviceId: {
119
type: 'SENSOR',
1210
code: 'sen-01'
@@ -19,9 +17,7 @@ db.anomaly.insert([
1917
__v: 0
2018
},
2119
{
22-
_id: {
23-
$oid: '65b514240718dbb3580fb9e8'
24-
},
20+
_id: '65b514240718dbb3580fb9e8',
2521
deviceId: {
2622
type: 'CAMERA',
2723
code: 'cam-03'
@@ -38,25 +34,17 @@ db.createCollection('notification')
3834

3935
db.notification.insert([
4036
{
41-
_id: {
42-
$oid: '65b5113633b1c7e038248937'
43-
},
44-
anomalyId: {
45-
$oid: '65b514200718dbb3580fb9e6'
46-
},
37+
_id: '65b5113633b1c7e038248937',
38+
anomalyId: '65b514200718dbb3580fb9e6',
4739
anomalyType: 'EXCEEDING',
4840
timestamp: {
4941
$date: '2024-01-27T14:20:38.950Z'
5042
},
5143
__v: 0
5244
},
5345
{
54-
_id: {
55-
$oid: '65b513ef0718dbb3580fb9e3'
56-
},
57-
anomalyId: {
58-
$oid: '65b514240718dbb3580fb9e8'
59-
},
46+
_id: '65b513ef0718dbb3580fb9e3',
47+
anomalyId: '65b514240718dbb3580fb9e8',
6048
anomalyType: 'INTRUSION',
6149
timestamp: {
6250
$date: '2024-01-27T14:32:15.925Z'
@@ -68,16 +56,12 @@ db.notification.insert([
6856
db.createCollection('securityRule')
6957
db.securityRule.insert([
7058
{
71-
_id: {
72-
$oid: '65b527590fa38e9a5422537c'
73-
},
59+
_id: '65b527590fa38e9a5422537c',
7460
deviceId: {
7561
type: 'SENSOR',
7662
code: 'sen-01'
7763
},
78-
creatorId: {
79-
$oid: '6582b78ee645d6402a3be6e2' // qui andra messo l'id dell'utente inserito nello script di auth db
80-
},
64+
creatorId: 'aaaaaaaaaaaaaaaaaaaaaaaa',
8165
description: 'Exceeding rule description',
8266
minValue: 0,
8367
maxValue: 25,
@@ -107,16 +91,12 @@ db.securityRule.insert([
10791
__v: 0
10892
},
10993
{
110-
_id: {
111-
$oid: '65b52e53cffd8e469604ef10'
112-
},
94+
_id: '65b52e53cffd8e469604ef10',
11395
deviceId: {
11496
type: 'CAMERA',
11597
code: 'cam-01'
11698
},
117-
creatorId: {
118-
$oid: '6582b78ee645d6402a3be6e2'
119-
},
99+
creatorId: 'aaaaaaaaaaaaaaaaaaaaaaab',
120100
description: 'Intrusion rule description',
121101
objectClass: 'PERSON',
122102
contacts: [
@@ -144,3 +124,50 @@ db.securityRule.insert([
144124
__v: 0
145125
}
146126
])
127+
128+
db.createCollection('recognizingNode')
129+
130+
db.recognizingNode.insert([
131+
{
132+
_id: '65a020d5de7178fe501e7dda',
133+
ipAddress: '192.168.1.2',
134+
deviceIds: [
135+
{
136+
type: 'CAMERA',
137+
code: 'cam-01',
138+
_id: {
139+
$oid: '65a10044aa628f95323324a9'
140+
}
141+
},
142+
{
143+
type: 'SENSOR',
144+
code: 'sen-01',
145+
_id: {
146+
$oid: '65a10044aa628f95323324aa'
147+
}
148+
}
149+
],
150+
__v: 0
151+
},
152+
{
153+
_id: '65a020d5de7178fe501e7ddb',
154+
ipAddress: '192.168.1.2',
155+
deviceIds: [
156+
{
157+
type: 'CAMERA',
158+
code: 'cam-02',
159+
_id: {
160+
$oid: '65a10044aa628f95323324b9'
161+
}
162+
},
163+
{
164+
type: 'SENSOR',
165+
code: 'sen-02',
166+
_id: {
167+
$oid: '65a10044aa628f95323324ac'
168+
}
169+
}
170+
],
171+
__v: 0
172+
}
173+
])

auth/db/auth-init.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ db.createCollection('user')
44
//TODO to test
55
db.user.insertMany([
66
{
7+
_id: 'aaaaaaaaaaaaaaaaaaaaaaaa',
78
name: 'Mattia',
89
surname: 'Matteini',
910
username: 'mattia',
@@ -17,6 +18,7 @@ db.user.insertMany([
1718
]
1819
},
1920
{
21+
_id: 'aaaaaaaaaaaaaaaaaaaaaaab',
2022
name: 'Mario',
2123
surname: 'Rossi',
2224
username: 'paga16',

monitoring/db/device-init.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,27 @@ db.device.insert([{
2626
'width': 200
2727
},
2828
'__v': 0
29+
}, {
30+
'_id': {
31+
'type': 'SENSOR',
32+
'code': 'sen-02'
33+
},
34+
'ipAddress': '192.168.1.30',
35+
'intervalMillis': 1000,
36+
'measures': [
37+
'PRESSURE',
38+
'TEMPERATURE'
39+
],
40+
'__v': 0
41+
}, {
42+
'_id': {
43+
'type': 'CAMERA',
44+
'code': 'cam-02'
45+
},
46+
'ipAddress': '192.168.1.40',
47+
'resolution': {
48+
'height': 200,
49+
'width': 200
50+
},
51+
'__v': 0
2952
}])

0 commit comments

Comments
 (0)