all repos — litestore @ 9113b340e656c32768d6d63d4012b8e05aa071f1

A minimalist nosql document store.

Added system documents lookup of custom resources.
h3rald h3rald@h3rald.com
Sat, 08 Feb 2020 12:49:35 +0100
commit

9113b340e656c32768d6d63d4012b8e05aa071f1

parent

452195706934e77dcfd272e6f24f980fd7d10098

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

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

@@ -915,8 +915,16 @@ proc execute*(req: LSRequest, LS:LiteStore, id: string): LSResponse =

var ctx = duk_create_heap_default() var ctx_idx = ctx.duk_push_object() var req_idx = ctx.duk_push_object() + var resource: string if not LS.customResources.hasKey(id): - return resError(Http404, "Custom resource '$1' not found." % id) + # Attempt to retrieve resource from system documents + let options = newQueryOptions(true) + let doc = LS.store.retrieveDocument("custom/" & id, options) + if doc.data == "": + return resError(Http404, "Custom resource '$1' not found." % id) + resource = doc.data + else: + resource = LS.customResources[id] # Create execution context ctx.duk_push_int(200) discard ctx.duk_put_prop_string(req_idx, "code")