diff --git a/add-repox-sets.xq b/add-repox-sets.xq
new file mode 100644
index 0000000..e421a4e
--- /dev/null
+++ b/add-repox-sets.xq
@@ -0,0 +1,9 @@
+declare namespace oai = "http://www.openarchives.org/OAI/2.0/";
+
+
+for $set in fn:doc('http://dpla.lib.utk.edu/repox/OAIHandler?verb=ListSets')/oai:OAI-PMH/oai:ListSets/oai:set
+let $spec := $set/oai:setSpec/text()
+let $name := $set/oai:setName/text()
+return(
+ db:add('repox-sets', {$spec}{$name}, $name)
+)
\ No newline at end of file
diff --git a/add-sets-to-db.xq b/add-sets-to-db.xq
new file mode 100644
index 0000000..22eda56
--- /dev/null
+++ b/add-sets-to-db.xq
@@ -0,0 +1,44 @@
+(: preface this with a COMMAND: `set addcache true; create db OAI` :)
+(: grab oai-pmh from repox :)
+declare namespace oai = "http://www.openarchives.org/OAI/2.0/";
+
+(: Retrieves metadata records for an entire OAI-PMH collection :)
+(: Adds records to BaseX database:)
+
+declare function local:request($base-url as xs:string, $verb as xs:string, $set-spec as xs:string) as document-node()*
+{
+ let $request := $base-url || $verb || $set-spec
+ let $response := fn:doc($request)
+ let $token := $response//oai:resumptionToken/text()
+ return
+ if (fn:empty($token)) then
+ $response
+ else
+ ($response,
+ local:resume($base-url, $token))
+};
+
+declare function local:resume($base-url as xs:string, $token as xs:string) as document-node()*
+{
+ let $verb := "?verb=ListRecords&resumptionToken="
+ let $request := $base-url || $verb || $token
+ let $response := fn:doc($request)
+ let $new-token := $response//oai:resumptionToken/text()
+ return
+ if (fn:empty($new-token)) then
+ $response
+ else
+ ($response,
+ local:resume($base-url, $new-token))
+};
+
+for $set in db:open('repox-sets')/set/spec/text()
+let $base-url := "http://dpla.lib.utk.edu/repox/OAIHandler" (: UTK's REPOX install :)
+let $verb := "?verb=ListRecords&metadataPrefix=oai_dc"
+let $set-spec := "&set=" || $set
+let $response := local:request($base-url, $verb, $set-spec)
+for $record in $response//oai:record
+let $id := $record/oai:header/oai:identifier/text()
+return(
+ db:add(($set), $record, $id, map { 'addcache': true() } )
+)
\ No newline at end of file
diff --git a/create-db-for-each-set.xq b/create-db-for-each-set.xq
new file mode 100644
index 0000000..1b5a89c
--- /dev/null
+++ b/create-db-for-each-set.xq
@@ -0,0 +1,5 @@
+(: this xquery script :)
+
+for $set in db:open('repox-sets')/set/spec/text()
+return
+ db:create(($set), (), (), map { 'textindex': true(), 'attrindex': true(), 'tokenindex': true(), 'ftindex': true() } )
\ No newline at end of file
diff --git a/create-repox-sets-db.bxs b/create-repox-sets-db.bxs
new file mode 100644
index 0000000..2fc913f
--- /dev/null
+++ b/create-repox-sets-db.bxs
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file