all repos — litestore @ 2d9918dac6d5b21a54cbd3f7656f7fd4cd042c5a

A minimalist nosql document store.

Add function for finding document by id matching given pattern
kaminski kaminski@naew.nato.int
Wed, 31 Mar 2021 21:20:17 +0200
commit

2d9918dac6d5b21a54cbd3f7656f7fd4cd042c5a

parent

c3daa777e9e0f4140545646b6650f5b55d31d6a5

1 files changed, 11 insertions(+), 0 deletions(-)

jump to
M src/litestorepkg/lib/core.nimsrc/litestorepkg/lib/core.nim

@@ -450,6 +450,17 @@ except:

eWarn() store.rollback() +proc findDocumentId*(store: Datastore, pattern: string): string = + var select = "SELECT id FROM documents WHERE id LIKE ? ESCAPE '\\' " + var raw_document = store.db.getRow(select.sql, pattern) + LOG.debug("Retrieving document '$1'" % pattern) + if raw_document[0] == "": + LOG.debug("(No Such Document)") + result = "" + else: + result = raw_document[0] + LOG.debug("Found id: $1" % result) + proc retrieveDocument*(store: Datastore, id: string, options: QueryOptions = newQueryOptions()): tuple[data: string, contenttype: string] =