#include "../dbutils/dbutils/sqlite.h"
#include "cx/mempool.h"
+#define SQL_REPOSITORY_GET_ALL "select * from repositories;"
+
#define SQL_NOTEBOOK_STRUCTURE "with recursive cols as (\n" \
" select 1 as depth, '' as path, * from resources where resource_id = ?\n" \
" union all\n" \
}
// NoteStore root object
- NoteStore *store = cxMalloc(a, sizeof(NoteStore));
+ NoteStore *store = cxZalloc(a, sizeof(NoteStore));
store->mp = mp;
- store->root = NULL;
- store->trash = NULL;
- store->repositories = cxLinkedListCreate(a, NULL, CX_STORE_POINTERS);
// key: resource_id value: Notebook*
CxMap *collection_map = cxHashMapCreate(NULL, CX_STORE_POINTERS, cxListSize(collections) + 16);
cxMapFree(collection_map);
+ // get repositories
+ DBUQuery *q2 = connection->createQuery(connection, NULL);
+ dbuQuerySetSQL(q2, SQL_REPOSITORY_GET_ALL);
+ DBUObjectBuilder *builder2 = dbuObjectBuilder(repository_class, q2, mp->allocator);
+ CxList *repositories = dbuObjectBuilderGetList(builder2);
+ if(!repositories) {
+ // TODO: error
+ } else {
+ store->repositories = repositories;
+ }
+ dbuObjectBuilderDestroy(builder2);
+
if(current_store) {
cxMempoolFree(current_store->mp);
}