all repos — litestore @ b2ed63e5ba33ff8777cf11525257ba427613e419

A minimalist nosql document store.

Fixed inconsistencies when deleting directory.
* Closes #41.
h3rald h3rald@h3rald.com
Sat, 14 Oct 2017 10:17:03 +0200
commit

b2ed63e5ba33ff8777cf11525257ba427613e419

parent

f71a83e924f1b045996cd45f8fc860a45b37e7f0

2 files changed, 9 insertions(+), 1 deletions(-)

jump to
M lib/core.nimlib/core.nim

@@ -398,9 +398,11 @@ file.writeFile(data)

LOG.info("Done."); proc deleteDir*(store: Datastore, dir: string) = - store.db.exec(SQL_DELETE_DOCUMENTS_BY_TAG, "$dir:"&dir) store.db.exec(SQL_DELETE_SEARCHDATA_BY_TAG, "$dir:"&dir) + store.db.exec(SQL_DELETE_DOCUMENTS_BY_TAG, "$dir:"&dir) store.db.exec(SQL_DELETE_TAGS_BY_TAG, "$dir:"&dir) + let total = store.db.getRow(SQL_COUNT_DOCUMENTS)[0].parseInt + store.db.exec(SQL_SET_TOTAL_DOCS, total) proc mountDir*(store: var Datastore, dir:string) = if not dir.dirExists:
M lib/queries.nimlib/queries.nim

@@ -62,6 +62,12 @@ const SQL_SELECT_INFO* = sql"""

SELECT * FROM info """ + +const SQL_SET_TOTAL_DOCS* = sql""" +UPDATE info +SET total_documents = ? +""" + const SQL_INCREMENT_DOCS* = sql""" UPDATE info SET total_documents = total_documents + 1