Skip to content

Commit f031b79

Browse files
Sensor conditions with ignore binary
1 parent dc9b587 commit f031b79

4 files changed

Lines changed: 41 additions & 23 deletions

File tree

src/repository/couch/SensorEventRepository.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ export class SensorEventRepository implements SensorEventInterface {
3232
],
3333
limit: Math.abs(limit ?? 1),
3434
})
35-
).docs.map((x: any) => ({
36-
...x,
35+
).docs.map((x: any) => {
36+
if(!!ignore_binary) {
37+
delete x.data
38+
}
39+
return({...x,
3740
_id: undefined,
3841
_rev: undefined,
3942
"#parent": undefined,
40-
})) as any
43+
})}) as any
4144
return all_res
4245
}
4346
public async _insert(participant_id: string, objects: SensorEvent[]): Promise<{}> {

src/repository/couch/SensorSpecRepository.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@ import { SensorSpecInterface } from "../interface/RepositoryInterface"
55
export class SensorSpecRepository implements SensorSpecInterface {
66
public async _select(id?: string, ignore_binary?: boolean): Promise<SensorSpec[]> {
77
const data = await Database.use("sensor_spec").list({ include_docs: true, start_key: id, end_key: id })
8-
return (data.rows as any).map((x: any) => ({
9-
id: x.doc._id,
10-
...x.doc,
11-
_id: undefined,
12-
_rev: undefined,
13-
}))
8+
return (data.rows as any).map((x: any) => {
9+
if(!!ignore_binary) {
10+
delete x.settings_schema
11+
}
12+
return({
13+
id: x.doc._id,
14+
...x.doc,
15+
_id: undefined,
16+
_rev: undefined,
17+
})
18+
})
1419
}
1520
public async _insert(object: SensorSpec): Promise<{}> {
1621
try {

src/repository/mongo/SensorEventRepository.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ export class SensorEventRepository implements SensorEventInterface {
3434
.limit(limit ?? 1)
3535
.maxTimeMS(60000)
3636
.toArray()
37-
return (all_res as any).map((x: any) => ({
38-
...x,
39-
_id: undefined,
40-
__v: undefined,
41-
_parent: undefined,
42-
_deleted: undefined,
43-
}))
37+
return (all_res as any).map((x: any) => {
38+
if(!!ignore_binary) {
39+
delete x.data
40+
}
41+
return({
42+
...x,
43+
_id: undefined,
44+
__v: undefined,
45+
_parent: undefined,
46+
_deleted: undefined,
47+
})
48+
})
4449
}
4550

4651
public async _insert(participant_id: string, objects: SensorEvent[]): Promise<{}> {

src/repository/mongo/SensorSpecRepository.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,18 @@ export class SensorSpecRepository implements SensorSpecInterface {
77
const data = !!id
88
? await MongoClientDB.collection("sensor_spec").find({$or: [ { _deleted: false, _id: id }, { _deleted: undefined, _id: id } ]}).maxTimeMS(60000).toArray()
99
: await MongoClientDB.collection("sensor_spec").find({$or: [ { _deleted: false }, { _deleted: undefined } ]}).maxTimeMS(60000).toArray()
10-
return (data as any).map((x: any) => ({
11-
id: x._id,
12-
...x,
13-
_id: undefined,
14-
__v: undefined,
15-
_deleted: undefined,
16-
}))
10+
return (data as any).map((x: any) => {
11+
if(!!ignore_binary) {
12+
delete x.settings_schema
13+
}
14+
return({
15+
id: x._id,
16+
...x,
17+
_id: undefined,
18+
__v: undefined,
19+
_deleted: undefined,
20+
})
21+
})
1722
}
1823
public async _insert(object: SensorSpec): Promise<{}> {
1924
try {

0 commit comments

Comments
 (0)