File tree Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Expand file tree Collapse file tree 3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ export default function Index() {
6363 < >
6464 < RemixLink to = "/links/add.html" className = "btn btn-primary mx-1" > < AdminIcon /> Add</ RemixLink >
6565 < RemixLink to = "/links/import.html" className = "btn btn-primary mx-1" > < AdminIcon /> Import</ RemixLink >
66+ < a href = "/links/backup.json" className = "btn btn-primary mx-1" > < AdminIcon /> Backup</ a >
6667 </ >
6768 : null }
6869 </ div >
Original file line number Diff line number Diff line change 1+ import { desc } from "drizzle-orm" ;
2+
3+ import { dborm } from "~/db/connection.server" ;
4+ import { regex_link } from "~/db/schema" ;
5+
6+ export async function loader ( ) {
7+
8+ const links = await dborm . select ( ) . from ( regex_link ) . orderBy ( desc ( regex_link . rxl_created_at ) ) ;
9+
10+ const jsonStr = JSON . stringify ( links ) ;
11+
12+ const date = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
13+
14+ return new Response ( jsonStr , {
15+ headers : {
16+ 'Access-Control-Allow-Origin' : '*' ,
17+ 'Access-Control-Allow-Methods' : 'POST, GET' ,
18+ 'Access-Control-Max-Age' : '604800' ,
19+ 'Content-Type' : 'application/json; charset=utf-8' ,
20+ 'Content-Disposition' : `attachment; filename="${ date } -backup_rz_links.json"` ,
21+ } ,
22+ } ) ;
23+ }
Original file line number Diff line number Diff line change @@ -65,8 +65,8 @@ export const action = async ({
6565 console . log ( JSON . stringify ( entry ) ) ;
6666 const existing = await dborm . select ( ) . from ( regex_link ) . where ( eq ( regex_link . rxl_url , entry . href ) ) ;
6767 if ( existing . length > 0 ) {
68- console . log ( "skipping" , entry . href ) ;
69- continue ;
68+ console . log ( `found ${ entry . href } , stopping...` ) ;
69+ break ;
7070 }
7171 console . log ( "inserting" , entry . href ) ;
7272 await dborm . insert ( regex_link ) . values ( {
You can’t perform that action at this time.
0 commit comments