Skip to content

Commit 195e8d2

Browse files
committed
Fix for running with mongodb v5
1 parent efafab1 commit 195e8d2

7 files changed

Lines changed: 20 additions & 6 deletions

File tree

OpenFlow/src/DatabaseConnection.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ export class DatabaseConnection {
149149
Logger.otel.endSpan(span);
150150
}
151151
async ListCollections(jwt: string): Promise<any[]> {
152-
const result = await DatabaseConnection.toArray(this.db.listCollections());
152+
let result = await DatabaseConnection.toArray(this.db.listCollections());
153+
result = result.filter(x => x.name.indexOf("system.") === -1);
153154
Crypt.verityToken(jwt);
154155
return result;
155156
}
@@ -2663,7 +2664,8 @@ export class DatabaseConnection {
26632664
const span: Span = Logger.otel.startSubSpan("db.ensureindexes", parent);
26642665
try {
26652666
if (!Config.ensure_indexes) return;
2666-
const collections = await DatabaseConnection.toArray(this.db.listCollections());
2667+
let collections = await DatabaseConnection.toArray(this.db.listCollections());
2668+
collections = collections.filter(x => x.name.indexOf("system.") === -1);
26672669

26682670
for (let i = 0; i < collections.length; i++) {
26692671
try {

OpenFlow/src/Messages/Message.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ export class Message {
748748
} else {
749749
span.addEvent("ListCollections");
750750
msg.result = await Config.db.ListCollections(msg.jwt);
751+
msg.result = msg.result.filter(x => x.name.indexOf("system.") === -1);
751752
span.addEvent("Filter collections");
752753
if (msg.includehist !== true) {
753754
msg.result = msg.result.filter(x => !x.name.endsWith("_hist"));
@@ -834,6 +835,8 @@ export class Message {
834835
span.recordException("Access denied, not signed in")
835836
msg.error = "Access denied, not signed in";
836837
} else {
838+
console.log("Query: " + JSON.stringify(msg.query, null, 4));
839+
console.log("Orderby: " + JSON.stringify(msg.orderby, null, 4));
837840
msg.result = await Config.db.query(msg.query, msg.projection, msg.top, msg.skip, msg.orderby, msg.collectionname, msg.jwt, msg.queryas, msg.hint, span);
838841
}
839842
} catch (error) {
@@ -4096,7 +4099,8 @@ export class Message {
40964099
const user = Crypt.rootUser();
40974100
const tuser = TokenUser.From(user);
40984101
const jwt: string = Crypt.rootToken();
4099-
const collections = await Config.db.ListCollections(jwt);
4102+
let collections = await Config.db.ListCollections(jwt);
4103+
collections = collections.filter(x => x.name.indexOf("system.") === -1);
41004104
let totalusage = 0;
41014105
let index = 0;
41024106
for (let col of collections) {

OpenFlow/src/public/Controllers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,12 @@ export class EntitiesCtrl extends entitiesCtrl<Base> {
29242924
if (!this.$scope.$$phase) { this.$scope.$apply(); }
29252925
WebSocketClientService.onSignedin(async (user: TokenUser) => {
29262926
try {
2927+
if (this.collection == "audit") {
2928+
if (this.orderby && this.orderby["_id"]) {
2929+
this.orderby["_created"] = this.orderby["_id"];
2930+
delete this.orderby["_id"];
2931+
}
2932+
}
29272933
this.loadData();
29282934
this.collections = await NoderedUtil.ListCollections(null);
29292935
} catch (error) {

OpenFlowNodeRED/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/nodered",
3-
"version": "1.3.54",
3+
"version": "1.3.55",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.3.54
1+
1.3.55

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openiap/openflow",
3-
"version": "1.3.54",
3+
"version": "1.3.55",
44
"description": "Simple wrapper around NodeRed, RabbitMQ and MongoDB to support a more scaleable NodeRed implementation.\r Also the \"backend\" for [OpenRPA](https://github.com/skadefro/OpenRPA)",
55
"main": "index.js",
66
"scripts": {

test/DatabaseConnection.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ import { Crypt } from '../OpenFlow/src/Crypt';
4343
}
4444
@test async 'ListCollections'() {
4545
var rootcollections = await Config.db.ListCollections(this.rootToken);
46+
rootcollections = rootcollections.filter(x => x.name.indexOf("system.") === -1);
4647
assert.notDeepStrictEqual(rootcollections, null);
4748
assert.notDeepStrictEqual(rootcollections.length, 0);
4849
}
4950
@test async 'DropCollections'() {
5051
const colname = "testcollection"
5152
var rootcollections = await Config.db.ListCollections(this.rootToken);
53+
rootcollections = rootcollections.filter(x => x.name.indexOf("system.") === -1);
5254
assert.notDeepStrictEqual(rootcollections, null);
5355
assert.notDeepStrictEqual(rootcollections.length, 0);
5456
var exists = rootcollections.filter(x => x.name == colname);

0 commit comments

Comments
 (0)