Skip to content

Commit

Permalink
Add docs to libsql functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ospfranco committed Nov 18, 2024
1 parent 2a25122 commit 15807dc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ export type DB = {
}[];
callback: (response: any) => void;
}) => () => void;
/** This function is only available for libsql.
* Allows to trigger a sync the database with it's remote replica
* In order for this function to work you need to use openSync or openRemote functions
* with libsql: true in the package.json
*
* The database is hosted in turso
**/
sync: () => void;
flushPendingReactiveQueries: () => Promise<void>;
};
Expand Down Expand Up @@ -405,6 +412,9 @@ function enhanceDB(db: DB, options: any): DB {
return enhancedDb;
}

/** Open a replicating connection via libsql to a turso db
* libsql needs to be enabled on your package.json
*/
export const openSync = (options: {
url: string;
authToken: string;
Expand All @@ -422,6 +432,9 @@ export const openSync = (options: {
return enhancedDb;
};

/** Open a remote connection via libsql to a turso db
* libsql needs to be enabled on your package.json
*/
export const openRemote = (options: { url: string; authToken: string }): DB => {
if (!isLibsql()) {
throw new Error('This function is only available for libsql');
Expand Down

0 comments on commit 15807dc

Please sign in to comment.