Started implementing index retrieval.
h3rald h3rald@h3rald.com
Sun, 12 Jan 2020 19:59:49 +0100
3 files changed,
10 insertions(+),
2 deletions(-)
M
src/litestorepkg/lib/api_v5.nim
→
src/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.nim
→
src/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.nim
→
src/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"