-
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.
- Loading branch information
Showing
4 changed files
with
104 additions
and
57 deletions.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// import Database from 'tauri-plugin-sql-api' | ||
|
||
// async function db(){ | ||
// const db = await Database.load('postgres://postgres:jammy-one@localhost:1234/postgres') | ||
// console.log('response', response) | ||
// return db | ||
// } | ||
|
||
// export default db | ||
|
||
import pgInit from 'pg-promise' | ||
|
||
const pgp = pgInit() | ||
export const db = pgp('postgres://postgres:jammy-one@localhost:1234/postgres') |
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,24 @@ | ||
import {db} from '../../../datamodel/db.js'; | ||
|
||
// eslint-disable-next-line import/no-anonymous-default-export | ||
export default async (_, res) => { | ||
await db.task(async t => { | ||
await t.none('DROP TABLE IF EXISTS message'); | ||
await t.none('DROP TABLE IF EXISTS replicache_client'); | ||
await t.none('DROP SEQUENCE IF EXISTS version'); | ||
// Stores chat messages | ||
await t.none(`CREATE TABLE message ( | ||
id VARCHAR(21) PRIMARY KEY NOT NULL, | ||
sender VARCHAR(255) NOT NULL, | ||
content TEXT NOT NULL, | ||
ord BIGINT NOT NULL, | ||
version BIGINT NOT NULL)`); | ||
// Stores last mutation ID for each Replicache client | ||
await t.none(`CREATE TABLE replicache_client ( | ||
id VARCHAR(36) PRIMARY KEY NOT NULL, | ||
last_mutation_id BIGINT NOT NULL)`); | ||
// Will be used for computing diffs for pull response | ||
await t.none('CREATE SEQUENCE version'); | ||
}); | ||
res.send('ok'); | ||
}; |