all repos — litestore @ c8dc3309c747fe1427dcf0546d0a6835e1ee3ccb

A minimalist nosql document store.

Started implementing index retrieval.
h3rald h3rald@h3rald.com
Sun, 12 Jan 2020 19:59:49 +0100
commit

c8dc3309c747fe1427dcf0546d0a6835e1ee3ccb

parent

879e3d3139299e8e61b869a6fb03b48227cde6e1

3 files changed, 10 insertions(+), 2 deletions(-)

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

@@ -478,7 +478,7 @@ try:

LS.store.createIndex(id, field) result.headers = ctJsonHeader() setOrigin(LS, req, result.headers) - result.content = "{\"index\": \"$1\"}" % id + result.content = "{\"id\": \"$1\", \"field\": \"$2\"}" % [id, field] result.code = Http200 except: eWarn()
M src/litestorepkg/lib/core.nimsrc/litestorepkg/lib/core.nim

@@ -127,6 +127,14 @@ store.begin()

store.db.exec(query) store.commit() +proc retrieveIndexes*(store: Datastore): JsonNode = + let raw_indexes= store.db.getAllRows(SQL_GET_DOCUMENTS_INDEXES) + var indexes = newSeq[JsonNode](0) + for index in raw_indexes: + # TODO: parse field + indexes.add(%[("id", %index[0]), ("field", %(index[1]))]) + return %indexes + # Manage Tags proc createTag*(store: Datastore, tagid, documentid: string, system = false) =
M src/litestorepkg/lib/queries.nimsrc/litestorepkg/lib/queries.nim

@@ -29,7 +29,7 @@ SQL_REINDEX* = sql"REINDEX"

SQL_OPTIMIZE* = sql"INSERT INTO searchdata(searchdata) VALUES('optimize')" SQL_REBUILD* = sql"INSERT INTO searchdata(searchdata) VALUES('rebuild')" - SQL_LIST_DOCUMENTS_INDEXES* = sql"select name, sql from sqlite_master where type = 'index' and tbl_name = 'documents' and name LIKE 'json_index_%'" + SQL_GET_DOCUMENTS_INDEXES* = sql"select name, sql from sqlite_master where type = 'index' and tbl_name = 'documents' and name LIKE 'json_index_%'" SQL_VACUUM* = sql"VACUUM"