Skip to content

Commit 2af2821

Browse files
committed
More JSDoc comments
1 parent b3bcf01 commit 2af2821

File tree

5 files changed

+19
-12
lines changed

5 files changed

+19
-12
lines changed

packages/powersync-react/src/hooks/usePowerSyncQuery.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { usePowerSync } from './PowerSyncContext';
33

44
/**
55
* A hook to access a single static query.
6-
* For an updated result, use usePowerSyncWatchedQuery instead
6+
* For an updated result, use {@link usePowerSyncWatchedQuery} instead
77
*/
88
export const usePowerSyncQuery = <T = any>(sqlStatement: string, parameters: any[] = []): T[] => {
99
const powerSync = usePowerSync();

packages/powersync-sdk-common/src/client/AbstractPowerSyncDatabase.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ import { EventIterator } from 'event-iterator';
2121
import { quoteIdentifier } from '../utils/strings';
2222

2323
export interface DisconnectAndClearOptions {
24+
/** When set to false, data in local-only tables is preserved. */
2425
clearLocal?: boolean;
2526
}
2627

2728
export interface PowerSyncDatabaseOptions {
29+
/** Schema used for the local database. */
2830
schema: Schema;
2931
database: DBAdapter;
3032
/**
@@ -436,15 +438,15 @@ export abstract class AbstractPowerSyncDatabase extends BaseObserver<PowerSyncDB
436438
}
437439

438440
/**
439-
* Execute a statement and optionally return results
441+
* Execute a statement and optionally return results.
440442
*/
441443
async execute(sql: string, parameters?: any[]) {
442444
await this.waitForReady();
443445
return this.database.execute(sql, parameters);
444446
}
445447

446448
/**
447-
* Execute a read-only query and return results
449+
* Execute a read-only query and return results.
448450
*/
449451
async getAll<T>(sql: string, parameters?: any[]): Promise<T[]> {
450452
await this.waitForReady();

packages/powersync-sdk-common/src/client/AbstractPowerSyncOpenFactory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Schema } from '../db/schema/Schema';
44
import { AbstractPowerSyncDatabase, PowerSyncDatabaseOptions } from './AbstractPowerSyncDatabase';
55

66
export interface PowerSyncOpenFactoryOptions extends Partial<PowerSyncDatabaseOptions> {
7+
/** Schema used for the local database. */
78
schema: Schema;
89
/**
910
* Filename for the database.

packages/powersync-sdk-common/src/client/connection/PowerSyncBackendConnector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface PowerSyncBackendConnector {
1616

1717
/** Upload local changes to the app backend.
1818
*
19-
* Use [PowerSyncDatabase.getCrudBatch] to get a batch of changes to upload. See [DevConnector] for an example implementation.
19+
* Use {@link AbstractPowerSyncDatabase.getCrudBatch} to get a batch of changes to upload.
2020
*
2121
* Any thrown errors will result in a retry after the configured wait period (default: 5 seconds).
2222
*/

packages/powersync-sdk-common/src/db/DBAdapter.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ import { BaseListener, BaseObserverInterface } from '../utils/BaseObserver';
1111
*/
1212

1313
/**
14-
* Object returned by SQL Query executions {
15-
* insertId: Represent the auto-generated row id if applicable
16-
* rowsAffected: Number of affected rows if result of a update query
17-
* message: if status === 1, here you will find error description
18-
* rows: if status is undefined or 0 this object will contain the query results
19-
* }
20-
*
21-
* @interface QueryResult
14+
* Object returned by SQL Query executions.
2215
*/
2316
export type QueryResult = {
17+
/** Represents the auto-generated row id if applicable. */
2418
insertId?: number;
19+
/** Number of affected rows if result of a update query. */
2520
rowsAffected: number;
21+
/** if status is undefined or 0 this object will contain the query results */
2622
rows?: {
2723
/** Raw array with all dataset */
2824
_array: any[];
@@ -37,12 +33,16 @@ export type QueryResult = {
3733
};
3834

3935
export interface DBGetUtils {
36+
/** Execute a read-only query and return results. */
4037
getAll<T>(sql: string, parameters?: any[]): Promise<T[]>;
38+
/** Execute a read-only query and return the first result, or null if the ResultSet is empty. */
4139
getOptional<T>(sql: string, parameters?: any[]): Promise<T | null>;
40+
/** Execute a read-only query and return the first result, error if the ResultSet is empty. */
4241
get<T>(sql: string, parameters?: any[]): Promise<T>;
4342
}
4443

4544
export interface LockContext extends DBGetUtils {
45+
/** Execute a statement and optionally return results. */
4646
execute: (query: string, params?: any[] | undefined) => Promise<QueryResult>;
4747
}
4848

@@ -63,6 +63,10 @@ export interface TableUpdateOperation {
6363
opType: RowUpdateType;
6464
rowId: number;
6565
}
66+
67+
/**
68+
* Notification of an update to one or more tables, for the purpose of realtime change notifications.
69+
*/
6670
export interface UpdateNotification extends TableUpdateOperation {
6771
table: string;
6872
}

0 commit comments

Comments
 (0)