appwrite-utils-cli 0.0.270 → 0.0.271

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.
package/README.md CHANGED
@@ -118,6 +118,7 @@ This setup ensures that developers have robust tools at their fingertips to mana
118
118
 
119
119
  ### Changelog
120
120
 
121
+ - 0.0.271: Small change to update attributes that are different from each other by deleting the attribute and recreating, as we cannot update most things
121
122
  - 0.0.270: Fixed enums in `--sync`, added optional OpenAPI generation (in progress, almost done, but wanted to push other changes), added `--endpoint`, `--project`, `--key` as optional parameters to change the target destination (shoutout to [pingu24k](https://github.com/pingu2k4) for pointing out these bugs and suggesting those changes for endpoint customization)
122
123
  - 0.0.254: Added `--sync` to synchronize your Appwrite instance with your local `appwriteConfig.yaml` and generate schemas
123
124
  - 0.0.253: Added `--writeData` (or `--write-data`) to command to write the output of the import data to a file called dataLoaderOutput in your root dir
@@ -1,5 +1,6 @@
1
1
  import { Query } from "node-appwrite";
2
2
  import { nameToIdMapping, enqueueOperation } from "./queue.js";
3
+ import _ from "lodash";
3
4
  export const createOrUpdateAttribute = async (db, dbId, collection, attribute) => {
4
5
  let action = "create";
5
6
  let foundAttribute;
@@ -10,12 +11,13 @@ export const createOrUpdateAttribute = async (db, dbId, collection, attribute) =
10
11
  foundAttribute = undefined;
11
12
  }
12
13
  let numSameAttributes = 0;
13
- if (foundAttribute && foundAttribute.key === attribute.key) {
14
+ if (foundAttribute && _.isEqual(foundAttribute, attribute)) {
14
15
  numSameAttributes++;
15
16
  return;
16
17
  }
17
- else if (foundAttribute) {
18
- action = "update";
18
+ else if (foundAttribute && !_.isEqual(foundAttribute, attribute)) {
19
+ console.log("Deleting attribute with same key but different values, assuming update...");
20
+ await db.deleteAttribute(dbId, collection.$id, attribute.key);
19
21
  }
20
22
  // Relationship attribute logic with adjustments
21
23
  let collectionFoundViaRelatedCollection;
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": "0.0.270",
4
+ "version": "0.0.271",
5
5
  "main": "src/main.ts",
6
6
  "type": "module",
7
7
  "repository": {
@@ -1,6 +1,7 @@
1
1
  import { Query, type Databases, type Models } from "node-appwrite";
2
2
  import type { Attribute } from "./schema.js";
3
3
  import { nameToIdMapping, enqueueOperation } from "./queue.js";
4
+ import _ from "lodash";
4
5
 
5
6
  export const createOrUpdateAttribute = async (
6
7
  db: Databases,
@@ -16,11 +17,14 @@ export const createOrUpdateAttribute = async (
16
17
  foundAttribute = undefined;
17
18
  }
18
19
  let numSameAttributes = 0;
19
- if (foundAttribute && foundAttribute.key === attribute.key) {
20
+ if (foundAttribute && _.isEqual(foundAttribute, attribute)) {
20
21
  numSameAttributes++;
21
22
  return;
22
- } else if (foundAttribute) {
23
- action = "update";
23
+ } else if (foundAttribute && !_.isEqual(foundAttribute, attribute)) {
24
+ console.log(
25
+ "Deleting attribute with same key but different values, assuming update..."
26
+ );
27
+ await db.deleteAttribute(dbId, collection.$id, attribute.key);
24
28
  }
25
29
 
26
30
  // Relationship attribute logic with adjustments