all repos — litestore @ b76275a419f74c82a8a8ce8aca1c618472c1d22d

A minimalist nosql document store.

Added auth.json lookup from system documents.
h3rald h3rald@h3rald.com
Sat, 08 Feb 2020 12:40:51 +0100
commit

b76275a419f74c82a8a8ce8aca1c618472c1d22d

parent

536308411859a02d00faa84e95d7a3ce49ee864b

2 files changed, 15 insertions(+), 4 deletions(-)

jump to
M src/litestore.nimsrc/litestore.nim

@@ -2,7 +2,8 @@ import

strutils, os, uri, - httpcore + httpcore, + json import litestorepkg/lib/types, litestorepkg/lib/logger,

@@ -98,6 +99,13 @@ vacuum LS.file

else: # Open Datastore setup(true) + +if LS.auth == newJNull(): + # Attempt to retrieve auth.json from system documents + let options = newQueryOptions(true) + let rawDoc = LS.store.retrieveRawDocument("auth.json", options) + if rawDoc != "": + LS.auth = rawDoc.parseJson() case LS.operation: of opRun:
M src/litestorepkg/lib/types.nimsrc/litestorepkg/lib/types.nim

@@ -121,7 +121,10 @@ "Access-Control-Allow-Headers": "Authorization, Content-Type",

"Server": LS.appname & "/" & LS.appversion } -proc newQueryOptions*(): QueryOptions = - return QueryOptions(select: @["documents.id AS id", "documents.data AS data", "content_type", "binary", "searchable", "created", "modified"], - single: false, limit: 0, offset: 0, orderby: "", tags: "", search: "", folder: "", like: "", +proc newQueryOptions*(system = false): QueryOptions = + var select = @["documents.id AS id", "documents.data AS data", "content_type", "binary", "searchable", "created", "modified"] + if system: + select = @["system_documents.id AS id", "system_documents.data AS data", "content_type", "binary", "created", "modified"] + return QueryOptions(select: select, + single: false, limit: 0, offset: 0, orderby: "", tags: "", search: "", folder: "", like: "", system: system, createdAfter: "", createdBefore: "", modifiedAfter: "", modifiedBefore: "", jsonFilter: "", jsonSelect: newSeq[tuple[path: string, alias: string]](), tables: newSeq[string]())