fix nedb to sqlite migrate

This commit is contained in:
Simon Smith 2023-09-07 19:35:03 +01:00 committed by GitHub
parent 7ea744fdfe
commit 23c2627b3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

10
db.js
View File

@ -1470,7 +1470,14 @@ module.exports.CreateDB = function (parent, func) {
obj.StoreEvent = function (event, func) { obj.StoreEvent = function (event, func) {
obj.dbCounters.eventsSet++; obj.dbCounters.eventsSet++;
sqlDbQuery('INSERT INTO events VALUES (NULL, $1, $2, $3, $4, $5, $6) RETURNING id', [event.time, ((typeof event.domain == 'string') ? event.domain : null), event.action, event.nodeid ? event.nodeid : null, event.userid ? event.userid : null, JSON.stringify(event)], function (err, docs) { sqlDbQuery('INSERT INTO events VALUES (NULL, $1, $2, $3, $4, $5, $6) RETURNING id', [event.time, ((typeof event.domain == 'string') ? event.domain : null), event.action, event.nodeid ? event.nodeid : null, event.userid ? event.userid : null, JSON.stringify(event)], function (err, docs) {
if ((err == null) && (docs[0].id)) { for (var i in event.ids) { if (event.ids[i] != '*') { sqlDbQuery('INSERT INTO eventids VALUES ($1, $2)', [docs[0].id, event.ids[i]]); } } } if(func){ func(); }
if ((err == null) && (docs[0].id)) {
for (var i in event.ids) {
if (event.ids[i] != '*') {
sqlDbQuery('INSERT INTO eventids VALUES ($1, $2)', [docs[0].id, event.ids[i]], function(){ if(func){ func(); } });
}
}
}
}); });
}; };
obj.GetEvents = function (ids, domain, func) { obj.GetEvents = function (ids, domain, func) {
@ -3239,6 +3246,7 @@ module.exports.CreateDB = function (parent, func) {
for (var i in docs) { for (var i in docs) {
pendingTransfer++; pendingTransfer++;
eventRecordsTransferCount++; eventRecordsTransferCount++;
for (var b in docs[i].ids) { if (docs[i].ids[b] != '*') { pendingTransfer++; } }
obj.StoreEvent(docs[i], function () { pendingTransfer--; }); obj.StoreEvent(docs[i], function () { pendingTransfer--; });
} }
} }