Skip to content

Commit

Permalink
Merge pull request #246 from tursodatabase/lucio/add-replicated
Browse files Browse the repository at this point in the history
release 0.9 & update libsql to 0.4
  • Loading branch information
LucioFranco committed Aug 9, 2024
2 parents 7803649 + 73ec295 commit b7a5475
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 89 deletions.
192 changes: 153 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/libsql-client-wasm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libsql/client-wasm",
"version": "0.8.1",
"version": "0.9.0",
"keywords": [
"libsql",
"database",
Expand Down Expand Up @@ -56,7 +56,7 @@
"typedoc": "rm -rf ./docs && typedoc"
},
"dependencies": {
"@libsql/core": "0.8.1",
"@libsql/core": "^0.9.0",
"@libsql/libsql-wasm-experimental": "^0.0.2",
"js-base64": "^3.7.5"
},
Expand Down
30 changes: 17 additions & 13 deletions packages/libsql-client-wasm/src/wasm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import type {
Value,
InValue,
InStatement,
InArgs
InArgs,
Replicated,
} from "@libsql/core/api";
import { LibsqlError } from "@libsql/core/api";
import type { ExpandedConfig } from "@libsql/core/config";
Expand Down Expand Up @@ -125,17 +126,20 @@ export class Sqlite3Client implements Client {
async execute(stmt: InStatement): Promise<ResultSet>;
async execute(sql: string, args?: InArgs): Promise<ResultSet>;

async execute(stmtOrSql: InStatement | string, args?: InArgs): Promise<ResultSet> {
let stmt: InStatement;

if (typeof stmtOrSql === 'string') {
stmt = {
sql: stmtOrSql,
args: args || []
};
} else {
stmt = stmtOrSql;
}
async execute(
stmtOrSql: InStatement | string,
args?: InArgs,
): Promise<ResultSet> {
let stmt: InStatement;

if (typeof stmtOrSql === "string") {
stmt = {
sql: stmtOrSql,
args: args || [],
};
} else {
stmt = stmtOrSql;
}

this.#checkNotClosed();
return executeStmt(this.#getDb(), stmt, this.#intMode);
Expand Down Expand Up @@ -186,7 +190,7 @@ export class Sqlite3Client implements Client {
}
}

async sync(): Promise<void> {
async sync(): Promise<Replicated> {
throw new LibsqlError(
"sync not supported in wasm mode",
"SYNC_NOT_SUPPORTED",
Expand Down
9 changes: 7 additions & 2 deletions packages/libsql-client/examples/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@ async function example() {
await db.execute(
"CREATE TABLE IF NOT EXISTS guest_book_entries (comment TEXT)",
);
await db.sync();
const rep = await db.sync();

console.log("frames_synced: " + rep.frames_synced);

const comment = reader.question("Enter your comment: ");

await db.execute({
sql: "INSERT INTO guest_book_entries (comment) VALUES (?)",
args: [comment],
});
await db.sync();

const rep2 = await db.sync();

console.log("frames_synced: " + rep2.frames_synced);

console.log("Guest book entries:");
const rs = await db.execute("SELECT * FROM guest_book_entries");
Expand Down
6 changes: 3 additions & 3 deletions packages/libsql-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@libsql/client",
"version": "0.8.1",
"version": "0.9.0",
"keywords": [
"libsql",
"database",
Expand Down Expand Up @@ -102,10 +102,10 @@
"lint-staged": "lint-staged"
},
"dependencies": {
"@libsql/core": "^0.8.1",
"@libsql/core": "^0.9.0",
"@libsql/hrana-client": "^0.6.2",
"js-base64": "^3.7.5",
"libsql": "^0.3.10",
"libsql": "^0.4.1",
"promise-limit": "^2.7.0"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit b7a5475

Please sign in to comment.