summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@scu.edu>2023-03-26 13:58:50 -0700
committerLouie Shprung <lshprung@scu.edu>2023-03-26 13:58:50 -0700
commit3c530aafe415db3515465e8b0662373065afd925 (patch)
tree3d6a4407c10d1b25abc17b3729c94c27b15488b2 /src/lib
parent78056b724b9a5591ea2361429ed2d83b2e528dcf (diff)
Index terms
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/create_table6
-rw-r--r--src/lib/insert9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/create_table b/src/lib/create_table
new file mode 100644
index 0000000..cdeb477
--- /dev/null
+++ b/src/lib/create_table
@@ -0,0 +1,6 @@
+create_table() {
+ DB_PATH="$1"
+
+ sqlite3 "$DB_PATH" "CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);"
+ sqlite3 "$DB_PATH" "CREATE UNIQUE INDEX IF NOT EXISTS anchor ON searchIndex (name, type, path);"
+}
diff --git a/src/lib/insert b/src/lib/insert
new file mode 100644
index 0000000..2e4dd8c
--- /dev/null
+++ b/src/lib/insert
@@ -0,0 +1,9 @@
+insert() {
+ DB_PATH="$1"
+ NAME="$2"
+ TYPE="$3"
+ PAGE_PATH="$4"
+
+ sqlite3 "$DB_PATH" "INSERT INTO searchIndex(name, type, path) VALUES (\"$NAME\",\"$TYPE\",\"$PAGE_PATH\");"
+}
+