@@ -14,17 +14,17 @@ interface SharedTableOptions {
1414 localOnly ?: boolean ;
1515 insertOnly ?: boolean ;
1616 viewName ?: string ;
17- includeOld ?: boolean | IncludeOldOptions ;
18- includeMetadata ?: boolean ;
19- ignoreEmptyUpdate ?: boolean ;
17+ trackOld ?: boolean | TrackOldOptions ;
18+ trackMetadata ?: boolean ;
19+ ignoreEmptyUpdates ?: boolean ;
2020}
2121
2222/** Whether to include old columns when PowerSync tracks local changes.
2323 *
2424 * Including old columns may be helpful for some backend connector implementations, which is
2525 * why it can be enabled on per-table or per-columm basis.
2626 */
27- export interface IncludeOldOptions {
27+ export interface TrackOldOptions {
2828 /** When defined, a list of column names for which old values should be tracked. */
2929 columns ?: string [ ] ;
3030 /** When enabled, only include values that have actually been changed by an update. */
@@ -56,9 +56,9 @@ export const DEFAULT_TABLE_OPTIONS = {
5656 indexes : [ ] ,
5757 insertOnly : false ,
5858 localOnly : false ,
59- includeOld : false ,
60- includeMetadata : false ,
61- ignoreEmptyUpdate : false
59+ trackOld : false ,
60+ trackMetadata : false ,
61+ ignoreEmptyUpdates : false
6262} ;
6363
6464export const InvalidSQLCharacters = / [ " ' % , . # \s [ \] ] / ;
@@ -200,9 +200,9 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
200200 viewName : options ?. viewName ,
201201 insertOnly : options ?. insertOnly ,
202202 localOnly : options ?. localOnly ,
203- includeOld : options ?. includeOld ,
204- includeMetadata : options ?. includeMetadata ,
205- ignoreEmptyUpdate : options ?. ignoreEmptyUpdate
203+ trackOld : options ?. trackOld ,
204+ trackMetadata : options ?. trackMetadata ,
205+ ignoreEmptyUpdates : options ?. ignoreEmptyUpdates
206206 } ;
207207 this . applyDefaultOptions ( ) ;
208208
@@ -212,9 +212,9 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
212212 private applyDefaultOptions ( ) {
213213 this . options . insertOnly ??= DEFAULT_TABLE_OPTIONS . insertOnly ;
214214 this . options . localOnly ??= DEFAULT_TABLE_OPTIONS . localOnly ;
215- this . options . includeOld ??= DEFAULT_TABLE_OPTIONS . includeOld ;
216- this . options . includeMetadata ??= DEFAULT_TABLE_OPTIONS . includeMetadata ;
217- this . options . ignoreEmptyUpdate ??= DEFAULT_TABLE_OPTIONS . ignoreEmptyUpdate ;
215+ this . options . trackOld ??= DEFAULT_TABLE_OPTIONS . trackOld ;
216+ this . options . trackMetadata ??= DEFAULT_TABLE_OPTIONS . trackMetadata ;
217+ this . options . ignoreEmptyUpdates ??= DEFAULT_TABLE_OPTIONS . ignoreEmptyUpdates ;
218218 }
219219
220220 get name ( ) {
@@ -255,16 +255,16 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
255255 return this . options . insertOnly ! ;
256256 }
257257
258- get includeOld ( ) {
259- return this . options . includeOld ! ;
258+ get trackOld ( ) {
259+ return this . options . trackOld ! ;
260260 }
261261
262- get includeMetadata ( ) {
263- return this . options . includeMetadata ! ;
262+ get trackMetadata ( ) {
263+ return this . options . trackMetadata ! ;
264264 }
265265
266- get ignoreEmptyUpdate ( ) {
267- return this . options . ignoreEmptyUpdate ! ;
266+ get ignoreEmptyUpdates ( ) {
267+ return this . options . ignoreEmptyUpdates ! ;
268268 }
269269
270270 get internalName ( ) {
@@ -298,10 +298,10 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
298298 throw new Error ( `Table has too many columns. The maximum number of columns is ${ MAX_AMOUNT_OF_COLUMNS } .` ) ;
299299 }
300300
301- if ( this . includeMetadata && this . localOnly ) {
301+ if ( this . trackMetadata && this . localOnly ) {
302302 throw new Error ( `Can't include metadata for local-only tables.` ) ;
303303 }
304- if ( this . includeOld != false && this . localOnly ) {
304+ if ( this . trackOld != false && this . localOnly ) {
305305 throw new Error ( `Can't include old values for local-only tables.` ) ;
306306 }
307307
@@ -341,17 +341,17 @@ export class Table<Columns extends ColumnsType = ColumnsType> {
341341 }
342342
343343 toJSON ( ) {
344- const includeOld = this . includeOld ;
344+ const trackOld = this . trackOld ;
345345
346346 return {
347347 name : this . name ,
348348 view_name : this . viewName ,
349349 local_only : this . localOnly ,
350350 insert_only : this . insertOnly ,
351- include_old : includeOld && ( ( includeOld as any ) . columns ?? true ) ,
352- include_old_only_when_changed : typeof includeOld == 'object' && includeOld . onlyWhenChanged == true ,
353- include_metadata : this . includeMetadata ,
354- ignore_empty_update : this . ignoreEmptyUpdate ,
351+ include_old : trackOld && ( ( trackOld as any ) . columns ?? true ) ,
352+ include_old_only_when_changed : typeof trackOld == 'object' && trackOld . onlyWhenChanged == true ,
353+ include_metadata : this . trackMetadata ,
354+ ignore_empty_update : this . ignoreEmptyUpdates ,
355355 columns : this . columns . map ( ( c ) => c . toJSON ( ) ) ,
356356 indexes : this . indexes . map ( ( e ) => e . toJSON ( this ) )
357357 } ;
0 commit comments