-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Establish db connection and basic search
- Loading branch information
Showing
22 changed files
with
321 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,7 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
|
||
.env | ||
.dev.vars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
mig_clt8pr6ikbucdv445tkg_16264466 | ||
mig_clt8pvh51tlm97jou9tg_50da88fb | ||
mig_clt8qep51tlm97joua5g_39219fe8 | ||
mig_clt8qg951tlm97joua7g_eb7523ab | ||
mig_clt8qm151tlm97joua8g_a673c218 | ||
mig_clt8qneikbucdv445u9g_e3a10c45 | ||
mig_clt8qr9ufgk57snhcv90_e296b93f | ||
mig_clt8r5951tlm97joua9g_9d118fb3 | ||
mig_clt8rb151tlm97jouaag_1632a9c3 | ||
mig_clt8u51ufgk57snhcva0_c24aa583 | ||
mig_clt8ul6ikbucdv445uag_dc5e54ff | ||
mig_clt8up6ikbucdv445ubg_47dad0b9 | ||
mig_clt8ut951tlm97jouabg_d5ce08c4 | ||
mig_clt8v0mikbucdv445ucg_25569b27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"id": "mig_clt8pr6ikbucdv445tkg", | ||
"checksum": "1:16264466529c465708d58829438f3ea695865e100ec7d4f1a20e4ee89e81f4bb", | ||
"operations": [ | ||
{ | ||
"addTable": { | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "mig_clt8pvh51tlm97jou9tg", | ||
"parentID": "mig_clt8pr6ikbucdv445tkg", | ||
"checksum": "1:50da88fbc9a220e6ec2f5d16fd1ea79af9e9384b2c785b3ef5f0dc92d7fcac9b", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "title", | ||
"type": "string" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id": "mig_clt8qep51tlm97joua5g", | ||
"parentID": "mig_clt8pvh51tlm97jou9tg", | ||
"checksum": "1:39219fe868101ac292a454d1c1713e8b8370a1b4822427ce40a5842d3fbc58d2", | ||
"operations": [ | ||
{ | ||
"removeTable": { | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"id": "mig_clt8qg951tlm97joua7g", | ||
"parentID": "mig_clt8qep51tlm97joua5g", | ||
"checksum": "1:eb7523ab119c0b2a29ec8f874ccb31e1bd0574a46093cadf76c3ca00eceabe85", | ||
"operations": [ | ||
{ | ||
"addTable": { | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "mig_clt8qm151tlm97joua8g", | ||
"parentID": "mig_clt8qg951tlm97joua7g", | ||
"checksum": "1:a673c218ed69470cd5ae2d9d824433ad1ff1c0e4ba17f6dc4f78c85b303f2f9b", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "title", | ||
"type": "string", | ||
"notNull": true, | ||
"defaultValue": "\"\"" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"id": "mig_clt8qneikbucdv445u9g", | ||
"parentID": "mig_clt8qm151tlm97joua8g", | ||
"checksum": "1:e3a10c455e3f8ea6a61a2b58a52101a8e2c6586a54b1510400c842ae3f5793e4", | ||
"operations": [ | ||
{ | ||
"removeColumn": { | ||
"column": "title", | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "mig_clt8qr9ufgk57snhcv90", | ||
"parentID": "mig_clt8qneikbucdv445u9g", | ||
"checksum": "1:e296b93f1c5d4f53bbf4e583cc22c443b20c6cd6703c37a35637f24c20f7edde", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "title", | ||
"type": "string", | ||
"notNull": true, | ||
"defaultValue": "" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "mig_clt8r5951tlm97joua9g", | ||
"parentID": "mig_clt8qr9ufgk57snhcv90", | ||
"checksum": "1:9d118fb3dfbf5fed2be74bb8c498303289476fab4c3cb64af21b9768dfd6f58f", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "true_title", | ||
"type": "string", | ||
"notNull": true, | ||
"defaultValue": "" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "mig_clt8rb151tlm97jouaag", | ||
"parentID": "mig_clt8r5951tlm97joua9g", | ||
"checksum": "1:1632a9c3a49f26b927bcb6d91a6862dfa6073f189ce63e8da230670adc2816da", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "extension", | ||
"type": "string", | ||
"notNull": true, | ||
"defaultValue": "" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"id": "mig_clt8u51ufgk57snhcva0", | ||
"parentID": "mig_clt8rb151tlm97jouaag", | ||
"checksum": "1:c24aa583a4b4d4cdff434f8eb70c5b59c3e5af80496ea80bc399362c0ff67db3", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "size", | ||
"type": "int", | ||
"notNull": true, | ||
"defaultValue": "0" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "mig_clt8ul6ikbucdv445uag", | ||
"parentID": "mig_clt8u51ufgk57snhcva0", | ||
"checksum": "1:dc5e54ff5462e0144d3633914899f97b0ce8d2c37ea83541bcea7123ab91635b", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "sources", | ||
"type": "multiple" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"id": "mig_clt8up6ikbucdv445ubg", | ||
"parentID": "mig_clt8ul6ikbucdv445uag", | ||
"checksum": "1:47dad0b9d387315cddc4f9a1b25dddb53f93ed48790efd2e186803c72ac7dcc8", | ||
"operations": [ | ||
{ | ||
"removeColumn": { | ||
"column": "sources", | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "mig_clt8ut951tlm97jouabg", | ||
"parentID": "mig_clt8up6ikbucdv445ubg", | ||
"checksum": "1:d5ce08c408263f80863055712da3e1bf066731e115fba5e10f2e40ee7d41007e", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "sources", | ||
"type": "multiple" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"id": "mig_clt8v0mikbucdv445ucg", | ||
"parentID": "mig_clt8ut951tlm97jouabg", | ||
"checksum": "1:25569b27226827636af25095c26d23e44d59e489c57aba56575b975a0a0ce596", | ||
"operations": [ | ||
{ | ||
"addColumn": { | ||
"column": { | ||
"name": "md5", | ||
"type": "string" | ||
}, | ||
"table": "Books" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"@xata.io/cli":{"latest":"0.15.3","compatibility":[{"range":">=0.0.0"}]},"@xata.io/client":{"latest":"0.28.2","compatibility":[{"range":">=0.0.0"}]}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"databaseURL": "https://lolibrary-92ghbn.us-east-1.xata.sh/db/lolibrary", | ||
"codegen": { | ||
"output": "src/lib/xata.ts" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { getXataClient } from "@/lib/xata"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
export const runtime = "edge"; | ||
|
||
const xata = getXataClient(); | ||
|
||
export async function GET(request: NextRequest) { | ||
const searchParams: string = decodeURIComponent( | ||
request.nextUrl.searchParams.toString() | ||
); | ||
|
||
const results = await xata.db.Books.search(searchParams, { | ||
target: ["title"], | ||
fuzziness: 0, | ||
}); | ||
|
||
return NextResponse.json({ results }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Generated by Xata Codegen 0.28.2. Please do not edit. | ||
import { buildClient } from "@xata.io/client"; | ||
import type { | ||
BaseClientOptions, | ||
SchemaInference, | ||
XataRecord, | ||
} from "@xata.io/client"; | ||
|
||
const tables = [ | ||
{ | ||
name: "Books", | ||
columns: [ | ||
{ name: "title", type: "string", notNull: true, defaultValue: "" }, | ||
{ name: "true_title", type: "string", notNull: true, defaultValue: "" }, | ||
{ name: "extension", type: "string", notNull: true, defaultValue: "" }, | ||
{ name: "size", type: "int", notNull: true, defaultValue: "0" }, | ||
{ name: "sources", type: "multiple" }, | ||
{ name: "md5", type: "string" }, | ||
], | ||
}, | ||
] as const; | ||
|
||
export type SchemaTables = typeof tables; | ||
export type InferredTypes = SchemaInference<SchemaTables>; | ||
|
||
export type Books = InferredTypes["Books"]; | ||
export type BooksRecord = Books & XataRecord; | ||
|
||
export type DatabaseSchema = { | ||
Books: BooksRecord; | ||
}; | ||
|
||
const DatabaseClient = buildClient(); | ||
|
||
const defaultOptions = { | ||
databaseURL: "https://lolibrary-92ghbn.us-east-1.xata.sh/db/lolibrary", | ||
}; | ||
|
||
export class XataClient extends DatabaseClient<DatabaseSchema> { | ||
constructor(options?: BaseClientOptions) { | ||
super({ ...defaultOptions, ...options }, tables); | ||
} | ||
} | ||
|
||
let instance: XataClient | undefined = undefined; | ||
|
||
export const getXataClient = () => { | ||
if (instance) return instance; | ||
|
||
instance = new XataClient(); | ||
return instance; | ||
}; |