wip: convert tauri sql to prisma

This commit is contained in:
Ren Amamiya
2023-04-02 16:22:50 +07:00
parent 9b8a96c651
commit 39e7c9bf34
11 changed files with 228 additions and 162 deletions

26
src/utils/bindings.ts Normal file
View File

@@ -0,0 +1,26 @@
// This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually.
declare global {
interface Window {
__TAURI_INVOKE__<T>(cmd: string, args?: Record<string, unknown>): Promise<T>;
}
}
const invoke = window.__TAURI_INVOKE__;
export function getAccount() {
return invoke<Account[]>('get_account');
}
export function createAccount(data: CreateAccountData) {
return invoke<Account>('create_account', { data });
}
export function createFollow(data: CreateFollowData) {
return invoke<Follow>('create_follow', { data });
}
export type Account = { id: number; pubkey: string; privkey: string; active: boolean; metadata: string };
export type Follow = { id: number; pubkey: string; kind: number; metadata: string; accountId: number };
export type CreateFollowData = { pubkey: string; kind: number; metadata: string; account_id: number };
export type CreateAccountData = { pubkey: string; privkey: string; metadata: string };

View File

@@ -9,6 +9,15 @@ export const tagsToArray = (arr) => {
return newarr;
};
export const followsTag = (arr) => {
const newarr = [];
// push item to tags
arr.forEach((item) => {
arr.push(['p', item]);
});
return newarr;
};
export const pubkeyArray = (arr) => {
const newarr = [];
// push item to newarr