Add function for finding document by id matching given pattern
kaminski kaminski@naew.nato.int
Wed, 31 Mar 2021 21:20:17 +0200
1 files changed,
11 insertions(+),
0 deletions(-)
jump to
M
src/litestorepkg/lib/core.nim
→
src/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] =