all repos — litestore @ 6575a2ad3baa1db496afea23d6ac259ac6f1284e

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

6575a2ad3baa1db496afea23d6ac259ac6f1284e

parent

aafc566246f43893549304f80d63608f7d4793f2

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] =