Skip to content

Include schema in database filter #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/yellow-cups-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/mysql-zongji': minor
---

Updated DatabaseFilter to take database/schema into account when matching tables
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,12 +342,12 @@ ZongJi.prototype._skipSchema = function (database, table) {
(database in includes &&
(includes[database] === true ||
(Array.isArray(includes[database]) && includes[database].indexOf(table) > -1) ||
(typeof includes[database] === 'function' && includes[database](table))));
(typeof includes[database] === 'function' && includes[database](table, database))));
let excluded =
database in excludes &&
(excludes[database] === true ||
(Array.isArray(excludes[database]) && excludes[database].indexOf(table) > -1) ||
(typeof excludes[database] === 'function' && excludes[database](table)));
(typeof excludes[database] === 'function' && excludes[database](table, database)));

return excluded || !included;
};
Expand Down
4 changes: 2 additions & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export type ZongjiOptions = {

/**
* Record specifying a database and specific tables. ie. ['MyDatabase']: ['table1', 'table2']
* OR a filter function that returns true for tables that should be included
* OR a filter function that returns true if a database.table combination should be included
* OR specifying true will include all tables in the database.
*/
interface DatabaseFilter {
[databaseName: string]: string[] | true | ((table: string) => boolean);
[database: string]: string[] | true | ((table: string, database: string) => boolean);
}

export type StartOptions = {
Expand Down