summaryrefslogtreecommitdiffstats
path: root/common/storage/entitystore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/storage/entitystore.cpp')
-rw-r--r--common/storage/entitystore.cpp16
1 files changed, 3 insertions, 13 deletions
diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp
index bb7c33c..4afb407 100644
--- a/common/storage/entitystore.cpp
+++ b/common/storage/entitystore.cpp
@@ -204,6 +204,7 @@ bool EntityStore::add(const QByteArray &type, const ApplicationDomain::Applicati
204 [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << entity.identifier() << newRevision; }); 204 [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << entity.identifier() << newRevision; });
205 DataStore::setMaxRevision(d->transaction, newRevision); 205 DataStore::setMaxRevision(d->transaction, newRevision);
206 DataStore::recordRevision(d->transaction, newRevision, entity.identifier(), type); 206 DataStore::recordRevision(d->transaction, newRevision, entity.identifier(), type);
207 DataStore::recordUid(d->transaction, entity.identifier());
207 SinkTraceCtx(d->logCtx) << "Wrote entity: " << entity.identifier() << type << newRevision; 208 SinkTraceCtx(d->logCtx) << "Wrote entity: " << entity.identifier() << type << newRevision;
208 return true; 209 return true;
209} 210}
@@ -327,6 +328,7 @@ bool EntityStore::remove(const QByteArray &type, const QByteArray &uid, bool rep
327 [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << uid << newRevision; }); 328 [&](const DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to write entity" << uid << newRevision; });
328 DataStore::setMaxRevision(d->transaction, newRevision); 329 DataStore::setMaxRevision(d->transaction, newRevision);
329 DataStore::recordRevision(d->transaction, newRevision, uid, type); 330 DataStore::recordRevision(d->transaction, newRevision, uid, type);
331 DataStore::removeUid(d->transaction, uid);
330 return true; 332 return true;
331} 333}
332 334
@@ -581,19 +583,7 @@ ApplicationDomain::ApplicationDomainType EntityStore::readPrevious(const QByteAr
581 583
582void EntityStore::readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback) 584void EntityStore::readAllUids(const QByteArray &type, const std::function<void(const QByteArray &uid)> callback)
583{ 585{
584 //TODO use a uid index instead 586 DataStore::getUids(d->getTransaction(), callback);
585 auto db = DataStore::mainDatabase(d->getTransaction(), type);
586 QByteArray lastUid;
587 db.scan("",
588 [&](const QByteArray &key, const QByteArray &) -> bool {
589 const auto uid = Sink::Storage::DataStore::uidFromKey(key);
590 if (uid != lastUid) {
591 lastUid = uid;
592 callback(uid);
593 }
594 return true;
595 },
596 [&](const Sink::Storage::DataStore::Error &error) { SinkWarningCtx(d->logCtx) << "Failed to read current value from storage: " << error.message; });
597} 587}
598 588
599bool EntityStore::contains(const QByteArray &type, const QByteArray &uid) 589bool EntityStore::contains(const QByteArray &type, const QByteArray &uid)