all repos — litestore @ bfc957ccaacd39c17cf973e6308aab93559caf01

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

bfc957ccaacd39c17cf973e6308aab93559caf01

parent

240ce0b144f9403fcb5098b69b3ee45f0c3c90ce

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")