appwrite-utils-cli 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -253,19 +253,13 @@ export class InteractiveCLI {
253
253
  ...configCollections.filter((c) => !remoteCollections.some((rc) => rc.name === c.name)),
254
254
  ];
255
255
  if (shouldFilterByDatabase) {
256
- // Enhanced filtering for tables with optional databaseId
256
+ // Show collections that EITHER exist in the remote database OR have matching local databaseId metadata
257
257
  allCollections = allCollections.filter((c) => {
258
- // For remote collections, they should match the selected database
259
- if (remoteCollections.some((rc) => rc.name === c.name)) {
260
- return c.databaseId === database.$id;
261
- }
262
- // For local collections/tables:
263
- // - Collections without databaseId are kept (backward compatibility)
264
- // - Tables with databaseId must match the selected database
265
- // - Tables without databaseId are kept (fallback for misconfigured tables)
266
- if (!c.databaseId)
267
- return true;
268
- return c.databaseId === database.$id;
258
+ // Include if it exists remotely in this database
259
+ const existsInRemoteDb = remoteCollections.some((rc) => rc.name === c.name);
260
+ // Include if local metadata claims it belongs to this database
261
+ const hasMatchingLocalMetadata = c.databaseId === database.$id;
262
+ return existsInRemoteDb || hasMatchingLocalMetadata;
269
263
  });
270
264
  }
271
265
  // Filter out system tables (those starting with underscore)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "appwrite-utils-cli",
3
3
  "description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.",
4
- "version": "1.6.1",
4
+ "version": "1.6.2",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -324,19 +324,15 @@ export class InteractiveCLI {
324
324
  ];
325
325
 
326
326
  if (shouldFilterByDatabase) {
327
- // Enhanced filtering for tables with optional databaseId
327
+ // Show collections that EITHER exist in the remote database OR have matching local databaseId metadata
328
328
  allCollections = allCollections.filter((c: any) => {
329
- // For remote collections, they should match the selected database
330
- if (remoteCollections.some((rc) => rc.name === c.name)) {
331
- return c.databaseId === database.$id;
332
- }
329
+ // Include if it exists remotely in this database
330
+ const existsInRemoteDb = remoteCollections.some((rc) => rc.name === c.name);
331
+
332
+ // Include if local metadata claims it belongs to this database
333
+ const hasMatchingLocalMetadata = c.databaseId === database.$id;
333
334
 
334
- // For local collections/tables:
335
- // - Collections without databaseId are kept (backward compatibility)
336
- // - Tables with databaseId must match the selected database
337
- // - Tables without databaseId are kept (fallback for misconfigured tables)
338
- if (!c.databaseId) return true;
339
- return c.databaseId === database.$id;
335
+ return existsInRemoteDb || hasMatchingLocalMetadata;
340
336
  });
341
337
  }
342
338